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 run a substitution over every quickfix hit and save only changed files?
:cdo s/foo/bar/ge | update
When quickfix already contains exactly the lines you want to touch, :cdo is the safest way to batch-edit with tight scope.
category:
command-line
tags:
#command-line
#quickfix
#substitution
#refactoring
How do I save only modified files across the argument list in Vim?
When working through an argument list, many files may remain unchanged.
category:
command-line
tags:
#command-line
#buffers
#ex-commands
#refactoring
How do I zero-pad every number in a buffer with one substitution?
:%s/\v(\d+)/\=printf('%04d', submatch(1))/g
When you need stable-width numeric fields, manual edits are slow and error-prone.
category:
command-line
tags:
#command-line
#substitution
#regex
#refactoring
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 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 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 can I print only arglist files that still contain trailing whitespace before bulk cleanup?
:argdo if search('\s\+$', 'nw') | echo expand('%') | endif
Before running destructive cleanup across many files, it helps to know which files will actually change.
category:
command-line
tags:
#command-line
#search
#whitespace
#arglist
#refactoring
How do I run a quickfix-wide replace without changing jumps or search history?
:cdo keepjumps keeppatterns %s/\<OldSymbol\>/NewSymbol/ge | update
When you run :cdo over a large quickfix list, Vim can leave your jump list noisy and your last search pattern overwritten.
category:
command-line
tags:
#quickfix
#ex-commands
#search
#editing
#refactoring
How do I run an interactive replacement across quickfix entries and only save changed files?
:cdo keeppatterns s/\<foo\>/bar/gec | update
When quickfix already contains precise targets, :cdo gives you a safer multi-file replace loop than broad project substitutions.
category:
command-line
tags:
#command-line
#quickfix
#substitute
#refactoring
How do I execute a command without changing '[ and '] marks in Vim?
Many batch edits in Vim update special marks like '[ and '], which can disrupt follow-up motions or tooling that depends on those positions.
category:
navigation
tags:
#navigation
#marks
#command-line
#refactoring
#editing
How do I copy the most recent yank into a named register without yanking again?
When you want to preserve a valuable yank before doing destructive edits, copying register 0 into a named register is safer than re-yanking text.
category:
registers
tags:
#registers
#yanking
#editing
#command-line
#refactoring
How do I use LSP for go-to-definition, references, and refactoring in Neovim?
gd / gr / <leader>rn with nvim-lspconfig
The Language Server Protocol (LSP) brings IDE-level intelligence to Neovim — go-to-definition, find references, rename symbol, and more.
category:
plugins
tags:
#plugins
#lsp
#neovim
#code-navigation
#refactoring
How do I edit multiple lines at once using multiple cursors in Vim?
The vim-visual-multi plugin (formerly vim-multiple-cursors) brings VS Code-style multiple cursor editing to Vim.
category:
plugins
tags:
#plugins
#visual-multi
#editing
#multiple-cursors
#refactoring
How do I split a single-line code statement into multiple lines or join them back in Vim?
The splitjoin.
category:
plugins
tags:
#plugins
#splitjoin
#editing
#refactoring
#formatting
How do I swap two text regions without using a temporary register in Vim?
The vim-exchange plugin by Tom McDonald provides the cx operator to swap two arbitrary text regions.
category:
plugins
tags:
#plugins
#exchange
#editing
#text-objects
#refactoring
How do I quickly convert between snake_case, camelCase, and other naming conventions in Vim?
The vim-abolish plugin by Tim Pope provides instant case coercion commands that convert the word under your cursor between common naming conventions.
category:
plugins
tags:
#plugins
#abolish
#editing
#refactoring
#naming
How do I search and replace a word while preserving its case variants in Vim?
The vim-abolish plugin by Tim Pope provides the :Subvert command (abbreviated :S), which performs search-and-replace operations that automatically handle every
category:
plugins
tags:
#plugins
#abolish
#search
#substitute
#refactoring