The Vim Cheatsheet
A modern, opinionated reference of the commands that actually earn their place in your muscle memory — from :q to q@a.
The Basics
The handful of commands you actually need on day one — entering, exiting, saving, and undoing.
Exiting Vim
The eternal question — finally answered.
| :q | Close file |
| :qa | Close all files |
| :w | Save |
| :wq | Save and close file |
| :x | Save and close file |
| ZZ | Save and quit |
| ZQ | Quit without checking changes |
| Esc / <C-[> | Exit insert mode |
| <C-C> | Exit insert mode and abort current command |
Word Navigation
Move around without ever touching the arrow keys.
| h / j / k / l | Left / down / up / right |
| <C-U> / <C-D> | Half-page up / down |
| <C-B> / <C-F> | Page up / down |
| b / w | Previous / next word |
| ge / e | Previous / next end of word |
| 0 | Start of line |
| ^ | Start of line (after whitespace) |
| $ | End of line |
Document Navigation
Jump across the file with surgical precision.
| f{char} | Jump forward to a character |
| F{char} | Jump backward to a character |
| t{char} | Jump until (before) a character |
| gg | First line |
| G | Last line |
| :{n} | Go to line {n} |
| {n}G | Go to line {n} |
| {n}j | Go down {n} lines |
| {n}k | Go up {n} lines |
| % | Jump to matching bracket |
Editing
Insert, append, replace — the core editing verbs.
| a | Append after cursor |
| A | Append at end of line |
| i | Insert before cursor |
| I | Insert at start of line |
| o | Open new line below |
| O | Open new line above |
| s | Delete character and insert |
| S | Delete line and insert |
| C | Change to end of line |
| r | Replace one character |
| R | Enter Replace mode |
| u | Undo |
| <C-R> | Redo |
| . | Repeat last change |
Visual Mode
Select first, act second.
| v | Enter visual mode |
| V | Enter visual line mode |
| <C-V> | Enter visual block mode |
| d / x | Delete selection |
| s | Replace selection |
| y | Yank selection (copy) |
| gv | Reselect last visual selection |
| o | Move cursor to other end of selection |
Clipboard
Cut, copy, paste — Vim style.
| x | Delete character |
| dd | Delete line (cut) |
| yy | Yank line (copy) |
| p | Paste after cursor |
| P | Paste before cursor |
| "*p / "+p | Paste from system clipboard |
| "*y / "+y | Yank to system clipboard |
| :reg | List all registers |
Operators
Operators act on a range of text defined by a motion. Combine them to express edits like sentences.
Operators list
See :help operator
| d | Delete |
| y | Yank (copy) |
| c | Change (delete then insert) |
| > | Indent right |
| < | Indent left |
| = | Auto-indent |
| g~ | Swap case |
| gU / gu | Uppercase / lowercase |
| ! | Filter through external program |
Examples
Compose operators with motions and counts.
| dd | Delete the current line |
| dw | Delete to next word |
| db | Delete to beginning of word |
| 2dd | Delete 2 lines |
| d$ | Delete to end of line |
| dip | Delete inside paragraph |
| ci" | Change inside double quotes |
| yi( | Yank inside parentheses |
| >ap | Indent a paragraph |
Text Objects
Operate on logical chunks — words, sentences, blocks, tags — with i (inside) or a (around).
Text objects
See :help text-objects
| p | Paragraph |
| w | Word |
| s | Sentence |
| [ ( { < | A bracket / brace block |
| ' " ` | A quoted string |
| b | A ( ) block |
| B | A { } block |
| t | An XML / HTML tag block |
Examples
Pair an operator with a text object.
| vip | Select inner paragraph |
| yip | Yank inner paragraph |
| yap | Yank paragraph (with newline) |
| dip | Delete inner paragraph |
| cip | Change inner paragraph |
| dit | Delete inside HTML / XML tag |
| ca{ | Change around braces |
Search & Replace
Find, jump, and rewrite text — from a single occurrence to every match in the file.
Searching
Incremental search and navigation.
| /pattern | Search forward |
| ?pattern | Search backward |
| n / N | Next / previous match |
| * | Search word under cursor (forward) |
| # | Search word under cursor (backward) |
| :noh | Clear search highlight |
| gd | Go to local definition |
Substitution
Replace patterns across lines, ranges, or the whole file.
| :s/foo/bar/ | Replace first match on line |
| :s/foo/bar/g | Replace all on current line |
| :%s/foo/bar/g | Replace all in file |
| :%s/foo/bar/gc | Replace all in file, confirm each |
| :'<,'>s/foo/bar/g | Replace within visual selection |
| :g/pattern/d | Delete lines matching pattern |
| :v/pattern/d | Delete lines NOT matching pattern |
Macros & Registers
Record sequences of commands and replay them. Store yanked text in named registers.
Macros
Record once, replay anywhere.
| q{a-z} | Start recording into register |
| q | Stop recording |
| @{a-z} | Replay macro from register |
| @@ | Replay last macro |
| {n}@{a-z} | Replay macro n times |
| :reg | List register contents |
Registers
Named clipboards for text and commands.
| "{a-z}y | Yank into named register |
| "{a-z}p | Paste from named register |
| "0 | Last yanked text |
| "+ / "* | System clipboard |
| "_ | Black hole — discard text |
| "% | Current file name |
| ": | Last Ex command |
Marks & Jumps
Bookmark positions in files and zip between them.
Marks
Set them with m, jump with ` or '.
| m{a-z} | Set mark in current buffer |
| m{A-Z} | Set global mark across files |
| `{mark} | Jump to exact mark position |
| '{mark} | Jump to start of mark's line |
| `. | Jump to last change |
| `` | Jump back to position before last jump |
| :marks | List all marks |
Jump list
Vim remembers where you've been.
| <C-O> | Jump to older position |
| <C-I> | Jump to newer position |
| :jumps | Show jump list |
| g; | Go to older change |
| g, | Go to newer change |
Windows, Buffers & Tabs
Split your screen, juggle buffers, and organize workspaces with tabs.
Windows
Split panes within the same Vim session.
| :sp / :split | Horizontal split |
| :vsp / :vsplit | Vertical split |
| <C-W>h/j/k/l | Move between windows |
| <C-W>w | Cycle windows |
| <C-W>q | Close window |
| <C-W>o | Close all other windows |
| <C-W>= | Equalize sizes |
| <C-W>_ | Maximize height |
| <C-W>| | Maximize width |
Buffers
Files Vim has loaded into memory.
| :ls / :buffers | List buffers |
| :b {name|n} | Switch to buffer |
| :bn / :bp | Next / previous buffer |
| :bd | Delete (close) buffer |
| :e {file} | Edit file in current window |
Tabs
Workspaces holding window layouts.
| :tabnew {file} | Open file in new tab |
| gt / gT | Next / previous tab |
| {n}gt | Go to tab n |
| :tabclose | Close tab |
| :tabonly | Close all other tabs |
Folding
Collapse regions of text so you can focus on what matters.
Folding commands
See :help folding
| zf{motion} | Create fold over motion |
| zo / zc | Open / close fold |
| za | Toggle fold |
| zR | Open all folds |
| zM | Close all folds |
| zd | Delete fold |
| zj / zk | Next / previous fold |
Power Tips
A handful of small commands that punch well above their weight.
Productivity boosters
Memorize these and never look back.
| . | Repeat the last change |
| ; | Repeat last f/F/t/T motion |
| , | Reverse last f/F/t/T motion |
| <C-A> | Increment number under cursor |
| <C-X> | Decrement number under cursor |
| J | Join line below into current line |
| gJ | Join without inserting a space |
| ~ | Toggle case of character |
| gq{motion} | Reformat text |
| <C-G> | Show file info |
Command line
Ex commands that pay rent.
| :help {topic} | Open help for topic |
| :e . | Open file explorer (netrw) |
| :!{cmd} | Run shell command |
| :r {file} | Insert contents of file |
| :r !{cmd} | Insert output of shell command |
| :set nu | Show line numbers |
| :set rnu | Show relative line numbers |
| :sort | Sort lines |
| :earlier 5m | Time-travel undo by 5 minutes |