How do I repeatedly run a macro while a pattern is still found in the buffer?
:while search('TODO') | normal! @q | endwhile
A fixed count like 100@q is brittle: sometimes your macro needs 12 passes, sometimes 300, and over-running can corrupt already-processed text.
category:
macros
tags:
#macros
#automation
#search
#normal-mode
#ex-commands
How do I reindent the whole buffer without adding jumplist entries?
:keepjumps normal! gg=G<CR>
Whole-buffer reindent is common, but doing it naively can pollute your jumplist and break navigation flow during review.
category:
command-line
tags:
#command-line
#formatting
#undo-redo
#workflow
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 run a normal mode command on multiple lines at once?
The :normal Ex command lets you execute any Normal mode keystrokes on a range of lines simultaneously, turning a single-line operation into a multi-line batch e
category:
editing
tags:
#editing
#normal-mode
#ex-commands
#visual-mode
#text-manipulation
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 run the last executed macro across an existing visual line range?
When you already have a useful macro but need to apply it to a specific block of lines, :'normal @@ is a high-leverage pattern.
category:
macros
tags:
#macros
#ex-commands
#visual-mode
#automation
How do I quit Vim without saving using a two-keystroke normal mode shortcut?
ZQ is the discard-and-quit counterpart to ZZ.
category:
editing
tags:
#editing
#normal-mode
#ex-commands
How do I create custom text objects for my own operator-pending motions?
onoremap ih :<C-u>execute "normal! ?^==\+$\r:noh\rkvg_"<CR>
Vim lets you define custom text objects using operator-pending mode mappings (onoremap) and visual mode mappings (vnoremap).
category:
config
tags:
#config
#text-objects
#mappings
#vimrc
#advanced
How do I run a normal mode command that bypasses all user-defined key mappings?
The :normal! command (abbreviated :norm!) executes a sequence of Normal mode keystrokes while completely ignoring user-defined mappings and abbreviations.
category:
command-line
tags:
#ex-commands
#normal-mode
#macros
#scripting
How do I reindent the whole file without adding extra jump-list entries?
Bulk formatting commands are common in cleanup sessions, but they often leave side effects in your navigation history.
category:
editing
tags:
#editing
#formatting
#ex-commands
#navigation
How do I run a recorded macro on every quickfix match without touching unrelated lines?
When a refactor target spans many files but only specific matches matter, running a macro globally is risky.
category:
macros
tags:
#macros
#quickfix
#automation
#ex-commands
How do I return to normal mode from absolutely any mode in Vim?
While works to leave insert or visual mode, it does not work in every situation — particularly in terminal mode (:terminal), where is consumed by the running
category:
navigation
tags:
#normal-mode
#insert-mode
#visual-mode
How do I run a single normal-mode command without leaving insert mode?
While typing in insert mode, you sometimes need to do a quick normal-mode action — center the screen, jump to a mark, or delete a word backward.
category:
editing
tags:
#insert-mode
#normal-mode
#editing
#motions
How do I run a macro on every line in a visual selection?
The :'normal @a command executes the macro stored in register a on every line within the current visual selection.
category:
macros
tags:
#macros
#visual-mode
#ex-commands
#editing
How do I run a macro or command on every entry in the location list?
:ldo runs an Ex command on each entry in the location list — the buffer-local cousin of the quickfix list.
category:
macros
tags:
#macros
#ex-commands
#editing
How do I make Neovim's background transparent so the terminal background color or wallpaper shows through?
vim.api.nvim_set_hl(0, 'Normal', {bg='NONE'})
By default, Neovim paints a solid background color defined by the active colorscheme.
category:
config
tags:
#neovim
#lua
#config
#highlight
#colorscheme
#transparency
How do I see where a normal-mode mapping was last defined in Vim?
When key behavior is inconsistent, the root cause is usually mapping precedence.
category:
command-line
tags:
#command-line
#mappings
#debugging
#config
#normal-mode
How do I execute a macro on each quickfix match and write files only when changed?
When you already have a precise quickfix list, :cdo is one of the safest ways to run a macro only where it matters.
category:
macros
tags:
#macros
#quickfix
#command-line
#automation
How do I run a normal mode command from the ex command line without triggering my custom key mappings?
:normal {command} runs a sequence of Normal mode keystrokes from the command line (or a range of lines with :%normal), but it applies your custom key mappings.
category:
command-line
tags:
#ex-commands
#macros
#normal-mode
#command-line
How do I apply a recorded macro to a specific set of files using the argument list?
:argdo execute 'normal @q' | update
:argdo runs an Ex command on every file in Vim's argument list (the arglist).
category:
macros
tags:
#macros
#ex-commands
#editing