Learn Vim / Do it again — vim

Do it again — vim

The answerCanonical keystrokes: qa I" Esc A" Esc j q @a @@.

Try it on a real buffer

Number these steps. Record a macro that prepends the right… actually simpler: each line needs wrapping in quotes. Record qa: I" Esc A" Esc j q on line 1. Replay on line 2 with @a, then just @@ to repeat on line 3.

apple
banana
cherry

Canonical solution: qa I" Esc A" Esc j q @a @@ · target: 13 keystrokes — the fewest that solve it (every keypress counts).

Why it works

@@ replays whatever macro you last ran — no need to name the register again. Run @a once, then @@ @@ … to keep going. The laziest, fastest loop in vim.

▶ live vim buffertarget 13 keystrokes
Number these steps. Record a macro that prepends the right… actually simpler: each line needs wrapping in quotes. Record qa: I" Esc A" Esc j q on line 1. Replay on line 2 with @a, then just @@ to repeat on line 3.

Reading about keystrokes doesn't build keystrokes. Try this in a real vim buffer right now — the “Do it again” mission takes about a minute.

Sign in free to practice →

Keep going