How do I add more commands to a macro I already recorded?
qA
If you finish recording a macro and realize you forgot a step, you don't need to re-record the whole thing.
macros #macros #registers #normal-mode #editing #productivity
52 results for "macro record qa"
qA
If you finish recording a macro and realize you forgot a step, you don't need to re-record the whole thing.
macros #macros #registers #normal-mode #editing #productivity
qa ... j@bj q
You can create macros that call other macros, applying different operations to alternate lines or creating complex editing patterns.
q{a-z}...q
Recording a macro captures a sequence of keystrokes into a register, which you can replay later.
qa Yp <C-a> q
By combining a macro with (increment number), you can quickly generate numbered sequences.
qaA;<Esc>jq
This macro appends a semicolon to the current line and moves down, ready to repeat.
qa...@aq
A recursive macro calls itself at the end of its recording, causing it to repeat until a motion or search fails.
qaI// <Esc>jq
This macro adds a // comment prefix to the beginning of the current line and moves down.
@a (within macro @b)
Vim macros can call other macros, enabling modular macro composition.
"+q{keys}q
You can record macros into any register, including the system clipboard (+).
qaciw"<C-r>""<Esc>wq
This macro wraps the current word in double quotes by changing the word, inserting quotes around the original content, and moving to the next word.
qaI<li><Esc>A</li><Esc>jq
This macro wraps each line in tags by inserting the opening tag at the start and appending the closing tag at the end.
qa<C-r>=expression<CR>q
How it works The expression register (=) lets you evaluate Vimscript expressions and insert the result.
qa<C-a>jq
By recording a one-step macro that increments a number and moves down a line, you can bulk-apply across as many lines as needed with a single count.
qagUiwWq2@a
Macros are most powerful when they encode both the edit and the movement to the next target.
qa{actions}@aq
A recursive macro is one that calls itself as its final action, causing it to repeat indefinitely until any command in the body fails (e.
qaq qa...@aq
A recursive macro calls itself at the end of its recording, causing it to repeat automatically until an error — such as reaching the end of the file — stops
Record worker macro in @b, call it from @a with @b
Complex macros are hard to debug and maintain when crammed into a single register.
qa0f:dwj0q
How it works When recording a macro that you plan to repeat across multiple lines, the key technique is to end the macro positioned on the next line, ready for
qaq
How it works To clear a macro register, you simply start recording into that register and immediately stop.
let @a = 'macro_contents'
Recorded macros are stored in registers, which are lost when you quit Vim (unless viminfo saves them).