Vim Cheatsheet
Power user.
Mode basics
Vim is modal. Most of the power lives in normal mode; insert mode is just for typing text. Composing commands across modes is what separates fluent users from new ones.
- Normal mode (Esc). Commands, navigation, deletions. The default landing mode and where most of the editing actually happens.
- Insert mode (i, a, o). Editing text.
iinserts at cursor,aappends after,oopens a new line below. - Visual mode (v, V, Ctrl-v). Selection. Linewise (V), characterwise (v), blockwise (Ctrl-v) for column edits.
- Command mode (:). Colon-prefixed actions. Save, quit, replace, run shell, anything that crosses outside the buffer.
Navigation
Navigation is what makes vim fast. Compose count plus motion plus object: 5dw deletes five words. The composition is the language; learn it once and the surface area shrinks.
- h, j, k, l. Left, down, up, right. Faster with prefix counts:
5jmoves down five lines without arrow-key thrash. - w, b, e. Word forward, back, end.
W, B, Efor WORD motions (whitespace-separated tokens). - gg, G, NG. Top of file, bottom of file, line N. The vertical trio.
- 0, ^, $. Line start, first non-blank, line end. The horizontal trio.
%jumps between matching brackets.
Editing
Editing in normal mode composes verbs (d, c, y) with motions (w, b, $) and text objects (iw, i", ip). Verb plus object is the core grammar.
- dd, yy, p, P. Delete line, yank line, paste after, paste before. The line-level toolkit.
- ciw, ci", cit. Change inner word, change inside double-quotes, change inside HTML tag. Text-object operations are where edit-time drops.
- d3w plus count-motion. Delete three words; count plus motion is the core composition that scales every other verb.
- u, Ctrl-r, dot. Undo, redo, repeat last change. The dot command alone is worth the learning curve.
Search and replace
Search and replace is where vim earns its keep on a ten-thousand-line file. Learn the regex flavour; it is POSIX with vim extensions and worth the muscle memory.
- /pattern, ?pattern, n, N. Search forward, backward, next match, previous match. The four keys cover most navigation needs.
- :%s/old/new/g. Replace globally in file. Append
cfor confirmation per match when the change is risky. - Star and hash.
*searches the word under the cursor forward,#backward. The fastest grep there is. - :noh, :g/pattern/d. Clear search highlight; delete every line matching a pattern. Bulk-edit verbs that replace external scripts.
Files and buffers
Vim handles many files at once via buffers. Most operators eventually pair vim with a fuzzy-finder plugin (fzf, telescope) but the core commands work standalone.
- :e file. Open file in current window. Tab-completion works on the path.
- :w, :wq, :q!. Save, save plus quit, discard plus quit. The explicit save is the one new users miss.
- :bn, :bp, :bd. Next, previous, close buffer. The buffer is the in-memory copy; closing it does not delete the file.
- :vsp, :sp, Ctrl-w arrows. Vertical split, horizontal split, navigate between windows. Side-by-side editing without leaving the editor.