Home

Vim Essential Commands and Tricks

Master these lesser-known, yet powerful, Vim commands to dramatically speed up your text editing workflow.


1. Quick Exits

Save precious seconds when closing files.

ActionCommandDescription
Save and QuitZZTwo capital Zs. A quick way to write changes and exit.
Quit without savingZQCapital Z, then Q. Quits without saving, similar to :q!.

2. Smart Text Selection & Modification (Inner Blocks)

Use the “inner block” motion (i) combined with block type to quickly target content within delimiters.

ActionCommandDescription
Select inside parentheses ()vibvisual inner block (or ‘b’ for balanced symbols).
Select inside curly braces {}viBvisual inner BRACE (capital B).
Change inside quotes ""ci"change inner quote. Works with '' and \` too.
Change inside parentheses ()cibQuickly deletes and puts you in insert mode.

3. Visual Block Mode for Multi-Line Edits

Perform operations on blocks of text across multiple lines.

ActionCommandDescription
Enter Block ModeCtrl+vUse this before selecting lines.
Insert at Start of BlockIWhile in Visual Block mode, press capital I to insert text that appears on every selected line after pressing Esc.
Append at End of BlockAAfter selecting the block (and pressing $), press capital A to append text to the end of every selected line after pressing Esc.
Re-select Last BlockgvJumps you back into Visual Block mode with the last block selected.

4. Navigation & Structure

Fluidly move around and clean up your code.

ActionCommandDescription
Re-indent the whole filegg=GGo to top (gg), apply auto-indent (=), go to bottom (G).
Jump between matching pairs%Place the cursor on a (, {, [, or similar symbol and jump to its match.
Jump to specific line number42GType the line number, then capital G.
Join lines with a spaceJCapital J joins the current line and the next with one space between them.
Join lines without a spacegJgJ joins the lines without adding a space.

5. Toggle Case

ActionCommandDescription
Toggle character case~In Normal mode, toggle the case of the character under the cursor.
Toggle word caseg~wToggle case for the current word.
Toggle case in a tagg~itToggle case for text inner tag.

6. Sessions, URLs, and Files

Quickly interact with your environment.

ActionCommandDescription
Suspend Vim to terminalCtrl+zTemporarily pauses Vim and returns you to the shell.
Return Vim to foregroundfgType fg in the terminal to resume your session.
Open URL under cursorgxOpens the web link under the cursor in your default browser.
Open file path under cursorgfOpens the file path under the cursor (if it exists in the Vim path).

7. Advanced Bookmarks (Marks)

Marks allow you to quickly jump between locations.

ActionCommandDescription
Set Mark (Current File)m followed by a lowercase letter (e.g., ma).Mark is only valid within the current file.
Jump to Mark (Current File)' followed by the lowercase letter (e.g., 'a).Jumps to the marked line and column.
Set Mark (Across Files)m followed by an uppercase letter (e.g., mA).Mark is valid across files and persists until Vim closes.
Jump to Mark (Across Files)' followed by the uppercase letter (e.g., 'A).Jumps to the correct file and line.
Tags: Vim, Cli, Learning