How do I collect multiple project searches into one location list instead of replacing results?
:lvimgrepadd /pattern/gj **/*
When investigating a bug or refactor, you often need to gather results from several related patterns before deciding what to edit.
category:
search
tags:
#search
#location-list
#quickfix
#ex-commands
How do I run a quickfix refactor once per file instead of once per match?
:cfdo %s/\<GetUser\>/FetchUser/ge | update
When quickfix has many matches per file, :cdo can execute your command repeatedly in the same buffer.
category:
command-line
tags:
#command-line
#quickfix
#refactoring
#ex-commands
#search
How do I recursively search files and load matches into quickfix in one command?
:vimgrep /\<TODO\>/gj **/*.lua | copen
When you want a project-wide TODO pass without leaving Vim, :vimgrep plus quickfix is a strong built-in workflow.
category:
search
tags:
#search
#quickfix
#command-line
#project-navigation
#ex-commands
How do I swap the first two whitespace-separated columns on every line?
:%s/\v(\S+)\s+(\S+)/\2 \1/<CR>
When you need to flip two fields across a whole file, a single substitution is faster and safer than recording a macro.
category:
editing
tags:
#editing
#substitution
#regex
#ex-commands
#formatting
How do I preview substitute changes inline while typing without opening a split?
When you are crafting a risky :substitute command, the expensive part is usually confidence, not typing.
category:
config
tags:
#config
#substitute
#search
#ex-commands
How do I keep a utility split from resizing when other windows open or close?
:setlocal winfixheight winfixwidth
If you use a dedicated utility pane (logs, quick notes, REPL output), Vim's default equalization behavior can keep resizing it whenever other splits change.
category:
buffers-windows
tags:
#buffers
#windows
#config
#ex-commands
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 improve Vim diff readability for moved or reindented code blocks?
:set diffopt+=algorithm:histogram,indent-heuristic
Default diff behavior can produce noisy hunks when code is moved or indentation changes significantly.
category:
config
tags:
#config
#buffers-windows
#ex-commands
#formatting
How do I replace only part of a match in :substitute without capture groups?
When your match has a stable prefix but you only want to replace the trailing segment, \zs is often cleaner than introducing extra capture groups.
category:
search
tags:
#search
#ex-commands
#formatting
#editing
How do I run a search-and-replace across all files in my argument list and only save changed buffers?
:argdo %s/\<old\>/new/ge | update
When you need to apply the same substitution across a curated set of files, :argdo is safer than a broad project-wide command.
category:
command-line
tags:
#command-line
#ex-commands
#search
#buffers
#formatting
How do I load shell command output into quickfix without running :grep?
:cgetexpr systemlist('rg --vimgrep TODO')
When you already have a shell command that emits file:line:col:message records, :cgetexpr is a fast way to populate quickfix directly.
category:
command-line
tags:
#quickfix
#command-line
#search
#ex-commands
How do I merge consecutive edits so they undo in a single step?
By default, separate edits often become separate undo entries, which makes replaying or backing out a multi-part change noisy.
category:
editing
tags:
#editing
#undo-redo
#ex-commands
#refactoring
How do I enable diff mode in every open split at once?
If you already have several related files open in splits, enabling diff mode one window at a time is slow and error-prone.
category:
buffers-windows
tags:
#buffers-windows
#diff
#windows
#ex-commands
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 execute a recorded macro once in each currently open window?
When you split a file into multiple windows or keep several related buffers visible, repeating the same small cleanup in each one can be tedious.
category:
macros
tags:
#macros
#windows
#normal-mode
#ex-commands
#automation
How do I remove trailing whitespace without clobbering @/ or showing no-match errors?
:silent keeppatterns %s/\s\+$//e
Trailing whitespace cleanup is a common housekeeping step, but a plain substitution can leave side effects: it can overwrite your last search pattern (@/) and t
category:
command-line
tags:
#command-line
#ex-commands
#editing
#search
#formatting
How do I run a normal-mode append on only matching lines inside a visual selection?
:'<,'>g/let /normal! A;<CR>
When you need a structural edit in part of a file, Visual mode ranges combine well with :global and :normal!.
category:
visual-mode
tags:
#visual-mode
#command-line
#ex-commands
#editing
How do I run a substitution across the arglist and write only modified files?
:argdo %s/foo/bar/ge | update
Bulk replacements across many files are risky when every buffer gets written unconditionally.
category:
command-line
tags:
#command-line
#arglist
#refactor
#ex-commands
How do I collapse consecutive duplicate words across a file?
:%s/\v<(\w+)\s+\1>/\1/g\<CR>
OCR cleanup, copy-paste artifacts, and rushed note-taking often produce repeated words like the the or is is.
category:
search
tags:
#search
#regex
#substitute
#ex-commands
How do I append a semicolon to every non-blank line with one Vim command?
:g/[^[:space:]]/normal! A;\<CR>
When you need to patch many lines at once, :g with :normal! is often faster and safer than recording a macro.
category:
command-line
tags:
#command-line
#ex-commands
#editing
#normal-mode