How do I append more commands to a recorded macro without re-recording it?
When a recorded macro is almost right but missing one repeated step, re-recording from scratch is usually slower and riskier than patching the register directly
category:
macros
tags:
#macros
#registers
#command-line
#normal-mode
How do I create a macro that runs continuously until it hits an error?
A recursive macro is a macro that calls itself as its last step, causing it to loop automatically until an operation fails (such as reaching the end of the file
category:
macros
tags:
#macros
#registers
#normal-mode
#editing
How do I apply a macro to every non-blank line in the file while skipping empty lines?
Combining the :global command with :normal lets you run a macro on every non-blank line in one shot.
category:
macros
tags:
#macros
#ex-commands
#global
#normal-mode
#editing
How do I create a macro that converts lines to a numbered list?
This simple macro inserts a list number prefix at the beginning of each line.
category:
macros
tags:
#macros
#editing
How do I run a macro on every line matching a pattern?
The :global command combined with :normal lets you execute a recorded macro on every line that matches a given pattern.
category:
macros
tags:
#macros
#command-line
#ex-commands
#global
#batch-editing
How do I inspect what key sequences are stored in a macro register?
When a macro behaves unexpectedly, :echo strtrans(@q) reveals exactly what is stored in register q—including invisible control characters—as human-readable
category:
macros
tags:
#macros
#registers
#debugging
How do I execute a macro from bottom to top over a selected range?
Running a macro over a range usually goes top to bottom, but that can break when the macro inserts or deletes lines.
category:
macros
tags:
#macros
#ex-commands
#visual-mode
#normal-mode
#refactoring
How do I convert a recorded macro into a permanent key mapping?
:let @q then use in nnoremap
Macros are stored in registers as plain keystroke strings.
category:
macros
tags:
#macros
#config
#vimrc
#mappings
#workflow
How do I replay a macro many times without cluttering the jumplist?
Running a macro hundreds of times is efficient, but it can flood your jumplist and make normal navigation painful afterward.
category:
macros
tags:
#macros
#automation
#normal-mode
#navigation
How do I combine two recorded macros into one without re-recording them from scratch?
Macros in Vim are stored as plain text in named registers.
category:
macros
tags:
#macros
#registers
#ex-commands
How do I run a macro on every line in the file silently, ignoring errors on lines where the macro fails?
Combining :silent!, the % range, and :normal @q gives you a powerful pattern for applying a macro across an entire file while gracefully skipping lines that don
category:
macros
tags:
#macros
#editing
#ex-commands
#normal-mode
How do I execute a macro while ignoring custom mappings that could change behavior?
Recorded macros can become fragile when your config defines mappings that shadow built-in keys.
category:
macros
tags:
#macros
#normal-mode
#mappings
#command-line
How do I apply a macro only to files that appear in the current location list?
:lfdo normal! @q | update
When you already have a curated location list, :lfdo lets you apply a change only to those files instead of touching your whole project.
category:
macros
tags:
#macros
#location-list
#refactoring
#command-line
#normal-mode
How do I copy a register to another register while preserving its character/line/block type?
:call setreg('q', getreg('a'), getregtype('a'))
Simple register copies can silently change behavior when register type is lost.
category:
registers
tags:
#registers
#macros
#command-line
#editing
How do I record and replay a macro in Vim?
Macros let you record a sequence of commands and replay them.
category:
macros
tags:
#macros
#automation
#registers
#normal-mode
How do I define or fix a macro using Vimscript instead of re-recording it?
Macros in Vim are just text stored in named registers.
category:
macros
tags:
#macros
#registers
#ex-commands
How do I run a macro a specific number of times without using a recursive macro?
Prefix a macro invocation with a count to execute it up to N times in a single command.
category:
macros
tags:
#macros
#registers
#normal-mode
#editing
How do I debug a Vim macro one command at a time?
Recorded macros are powerful, but when one keystroke goes wrong they can fail fast and leave confusing state behind.
category:
macros
tags:
#macros
#debugging
#normal-mode
#workflow
How do I change the cursor shape for different Vim modes in the terminal?
Modern terminals support cursor shape changes via escape sequences.
category:
config
tags:
#config
#cursor
#terminal
#visual-feedback
How do I send Telescope results to the quickfix list for bulk editing?
While inside any Telescope picker, pressing sends all current results to the quickfix list and closes the picker.
category:
plugins
tags:
#plugins
#search
#quickfix
#buffers-windows