How do I add more steps to an existing macro without re-recording it from scratch?
Answer
qQ
Explanation
When you realize a recorded macro is missing a step at the end, you don't need to re-record the whole thing. Using an uppercase register letter to start recording appends to the existing macro rather than replacing it. If your macro is in register q, typing qQ begins an append recording session.
How it works
q{register}— starts recording into the specified register (replaces existing content)q{REGISTER}— starts recording with an uppercase letter, which appends to the register- So
qQappends new keystrokes to whatever is already stored in registerq - Press
qagain to stop recording, just as normal
This works because uppercase and lowercase letters refer to the same named register, but uppercase signals an append operation — the same mechanism used with "Ayy to append yanked text.
Example
Suppose you recorded qq to add a semicolon and move down:
qq " start recording into q
A;<Esc> " append semicolon
j " move down
q " stop recording
You later realize you also need to move to the beginning of the line. Instead of re-recording:
qQ " append to macro q
0 " go to beginning of line
q " stop recording
Now @q does: append semicolon → move down → go to line start.
Tips
- Works with any named register (
a–z):qA,qB, etc. - View the full macro contents with
:reg qbefore and after to confirm the append - Use
:let @q = @q . "\<Esc>"for programmatic appends when the content involves special keys