How do I add more steps to an existing macro without re-recording it from scratch?
Answer
qQ...q
Explanation
When you record a macro into register q with qq...q, you might realize you forgot a step. Instead of re-recording the entire macro, you can append to it by recording with the uppercase version of the register letter. Using qQ starts recording and appends new keystrokes to whatever is already stored in register q.
How it works
qq...q— records a macro into registerq(overwrites any previous content)qQ...q— records and appends to registerq(preserves existing content, adds new keystrokes at the end)
The uppercase letter convention works for all 26 named registers (a-z). Recording into A appends to a, recording into B appends to b, and so on.
Example
Suppose you recorded a macro to add a semicolon at end of line:
qqA;q
Now you realize the macro should also move to the next line. Instead of re-recording:
qQjq
Register q now contains A;j — append semicolon, then move down. Running @q repeatedly processes line after line.
Tips
- This works with
:let @q .= 'j'too, if you prefer editing the register directly - View the current macro contents with
:reg q - You can paste a register into the buffer with
"qp, edit it, then yank it back with"qyyfor precise macro editing