A quick reference for Vim commands. Covers modes, navigation, editing, search/replace, visual mode, registers, macros, and window management.
Modes
| Key | Description |
|---|---|
| Esc | Return to Normal mode |
| i | Insert mode (before cursor) |
| a | Insert mode (after cursor) |
| v | Visual mode (character selection) |
| V | Visual Line mode (line selection) |
| Ctrl+v | Visual Block mode (column selection) |
| : | Command-line mode |
| R | Replace mode (overwrite text) |
Navigation
| Key | Description |
|---|---|
| h / j / k / l | Left / down / up / right |
| w / b | Next word / previous word |
| e | End of current word |
| 0 / $ | Start / end of line |
| ^ | First non-blank character of line |
| gg / G | Go to first / last line |
| :<number> | Go to line number |
| Ctrl+d / Ctrl+u | Half-page down / up |
| Ctrl+f / Ctrl+b | Full page down / up |
| % | Jump to matching bracket |
Editing
| Key | Description |
|---|---|
| i / a | Insert before / after cursor |
| I / A | Insert at start / end of line |
| o / O | New line below / above |
| dd | Delete (cut) current line |
| dw | Delete word from cursor |
| d$ / D | Delete to end of line |
| yy | Yank (copy) current line |
| yw | Yank word from cursor |
| p / P | Paste after / before cursor |
| u / Ctrl+r | Undo / redo |
| x | Delete character under cursor |
| r<char> | Replace character under cursor |
Search & Replace
| Command | Description |
|---|---|
| /pattern | Search forward for pattern |
| ?pattern | Search backward for pattern |
| n / N | Next / previous match |
| * | Search for word under cursor |
| :s/old/new/ | Replace first on current line |
| :s/old/new/g | Replace all on current line |
| :%s/old/new/g | Replace all in entire file |
| :%s/old/new/gc | Replace all with confirmation |
Visual Mode
| Key | Description |
|---|---|
| v | Start character-wise selection |
| V | Start line-wise selection |
| Ctrl+v | Start block-wise selection |
| d | Delete selected text |
| y | Yank selected text |
| > | Indent selected lines |
| < | Unindent selected lines |
| gq | Reformat selected text |
Registers & Macros
| Command | Description |
|---|---|
| "ay | Yank into register a |
| "ap | Paste from register a |
| :reg | Show all register contents |
| "+ y | Yank to system clipboard |
| qa | Start recording macro into register a |
| q | Stop recording macro |
| @a | Play macro from register a |
| @@ | Replay last macro |
Window Management
| Command | Description |
|---|---|
| :sp file | Horizontal split |
| :vsp file | Vertical split |
| Ctrl+w h/j/k/l | Move between splits |
| Ctrl+w = | Equalize split sizes |
| Ctrl+w _ | Maximize current split height |
| Ctrl+w | | Maximize current split width |
| :tabnew file | Open file in new tab |
| gt / gT | Next / previous tab |
Common Commands
| Command | Description |
|---|---|
| :w | Save file |
| :q | Quit (fails if unsaved changes) |
| :wq / :x | Save and quit |
| :q! | Quit without saving |
| :e file | Open file for editing |
| :set number | Show line numbers |
| :set paste | Enable paste mode (no auto-indent) |
| . | Repeat last change |