Learn Vim / Multiply the macro — vim

Multiply the macro — vim

The answerCanonical keystrokes: qa r* j q 5@a.

Try it on a real buffer

Six lines, same fix: turn each “- ” into “* ”. Record the fix for line 1 with qa (change the dash, step down), q to stop, then replay it five times at once with 5@a.

- one
- two
- three
- four
- five
- six

Canonical solution: qa r* j q 5@a · par: 9 keystrokes (vimgolf rules — every keypress counts).

Why it works

A count in front of a macro runs it that many times: 5@a is @a @a @a @a @a. Record a clean one-line fix that ends by moving to the next line, and a single count finishes the whole list.

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

Practice free — no signup →

Keep going