One key to repeat them all
If you learn a single "advanced" Vim command from this entire quest, make it the dot command: . repeats your last change. It is easily the most powerful single keystroke in Vim, and it's the engine behind why experienced users look so fast.
What counts as a "change"
A change is anything that modifies the buffer between entering and leaving Normal mode. Examples:
dd— delete a line..deletes the next line.cwhelloEsc— change a word to "hello"..changes the next word to "hello".A;Esc— append a semicolon..appends a semicolon to whichever line you're on now.I//Esc— comment-out a line..comments-out the next line you point at.
The dot formula
Drew Neil's Practical Vim distilled the essence: one keystroke to move, one keystroke to repeat the change. Your edit loop becomes n., j., ;. — find next, repeat. Once your fingers find this rhythm, batch edits feel like playing a metronome instead of typing.
cw over dwi (one change vs two). Prefer A; over $a;. The first edit is the same speed; the difference shows up on edits two through ten when you press . and the previous version doesn't replay correctly.Two patterns you'll use forever
Pattern 1: search + dot. Use / or * to find the next occurrence, make a change, then n., n., n. — done across the whole file. The search command itself is repeated by n, and the change is repeated by .. Two hand motions, infinite reach.
Pattern 2: line jump + dot. Make the change once, then j., j., j. walks down the file applying it. Or }. to jump by paragraphs. Or }.}.. Each repeat costs you exactly two keys.
What dot doesn't repeat
- Pure motion —
j,w,$aren't changes, so dot ignores them. - Command-line operations like
:s/old/new/g. Use&or:&for those. - Macros — those have their own replay key,
@@.