Learn Vim / Record once, replay — vim

Record once, replay — vim

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

Try it on a real buffer

Every line needs a trailing semicolon. Record a macro into a: press qa, then A; Esc j to fix line 1 and step down, then q to stop. Now replay it on the other lines with @a, @a.

let a = 1
let b = 2
let c = 3

Canonical solution: qa A; Esc j q @a @a · par: 11 keystrokes (vimgolf rules — every keypress counts).

Why it works

qa starts recording into register a; every keystroke is captured until you press q again. @a replays the whole sequence. Record the fix for ONE line (ending by moving to the next), then replay for the rest.

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

Practice free — no signup →

Keep going