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
45 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
When recording a macro, you can execute another macro inside it by pressing @b (or any register) during the recording.
qa ... q ... @a
Macros let you record a sequence of commands and replay them.
qa/^$/\ndd@aq
Record a macro that searches for blank lines, deletes them, and recurses.
qa/^#\nddq
Record a macro that finds lines starting with # and deletes them.
qa...q
Press q followed by a lowercase letter (a-z) to start recording into that register.
qa/[A-Z]\ni_<Esc>l~q
Record a macro that finds the next uppercase letter, inserts an underscore before it, and lowercases it.
qa:s/^ / /\njq
Record a macro that substitutes leading 4-space indentation with 2 spaces on each line.
qa:s/\s\+$//e\n jq
Record a macro that runs a substitution on the current line to remove trailing spaces, then moves down.
qa:s/\t/ /g\njq
Record a macro that substitutes all tabs with spaces on the current line, then moves down.
qa/https\?:\/\/\nyiW:put\nq
Record a macro that searches for URLs, yanks the URL, and puts it at the end of the file.
@a (within macro @b)
Vim macros can call other macros, enabling modular macro composition.
qa ... j@bj q
You can create macros that call other macros, applying different operations to alternate lines or creating complex editing patterns.
qa/true\|false\ncgn<C-r>=@"=='true'?'false':'true'\n<Esc>q
Record a macro using cgn with an expression register to toggle between true and false.
qa/pattern\nyy}pq
Record a macro that searches for a pattern, yanks the matching line, goes to the end of the paragraph, and pastes it.
qa{edits}@bq
How it works Vim macros can call other macros, creating a modular system of reusable building blocks.
qa{jI## Section \n<Esc>}q
Record a macro that goes to the start of each paragraph and inserts a section header.
qa$bywdw0Pa <Esc>q
Record a macro that yanks the last word, deletes it, pastes it at the beginning of the line.
"+q{keys}q
You can record macros into any register, including the system clipboard (+).
qa ci"replacement<Esc> /next<CR> q
Macros can contain any Vim command including text objects, searches, and multi-key motions.