How do I record a macro in Vim?
Answer
q{a-z}...q
Explanation
Recording a macro captures a sequence of keystrokes into a register, which you can replay later. Press q followed by a register letter to start, perform your actions, then press q again to stop.
How it works
qastarts recording into registera- Perform any sequence of Vim commands
qstops recording@areplays the macro
Example
To wrap each line in <li> tags:
qa— start recordingI<li><Esc>A</li><Esc>j— add tags and move downq— stop recording@a— replay on next line
Tips
@@replays the last macro5@aruns macroafive times- The recording indicator appears in the statusline
- All 26 registers (a-z) can store macros
- Macros and registers share the same storage