How do I clear a macro register to start fresh without using Vimscript?
Answer
qqq
Explanation
Pressing qqq in normal mode is the quickest way to empty a macro register. The first q starts a recording session into register q, and the second q immediately stops it — recording nothing. The result is an empty register, effectively deleting whatever macro was stored there.
How it works
qq— start recording a macro into registerqq— stop recording immediately (nothing was typed)- The register
qnow contains an empty string
This pattern works for any register letter. To clear register a, type qaq. To clear register w, type qwq.
Example
Suppose you accidentally record a broken macro into q:
Press @q → runs a mangled sequence, bad output
Clear it with qqq, then re-record cleanly:
qq " start new recording
cW fix<Esc> " record the intended edit
q " stop recording
Now @q runs only the intended edit.
Tips
- Alternative:
:let @q = ''achieves the same result from the command line - Use
:reg qto inspect the current contents of a register before clearing - Clearing a macro is useful before using it as a recursive macro, to ensure there is no residual content interfering with the recursion