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 run a replacement only over the current window's location-list matches?
:ldo s/foo/bar/ge | update\<CR>
:ldo is one of the most effective ways to perform targeted, multi-file edits without touching unrelated text.
category:
command-line
tags:
#command-line
#search
#ex-commands
#buffers
How do I pipe selected text through an external command and replace it?
The ! operator in normal mode pipes text through an external shell command and replaces it with the output.
category:
command-line
tags:
#command-line
#shell
#editing
#filtering
#unix
How do I highlight a custom pattern in the current window without affecting the search register?
:call matchadd('ErrorMsg', 'TODO')
matchadd() lets you highlight arbitrary patterns using any highlight group — without touching the search register or search highlighting.
category:
config
tags:
#search
#config
#normal-mode
How do I re-indent the entire paragraph under my cursor to match the surrounding code?
The =ip command combines Vim's auto-indent operator (=) with the inner paragraph text object (ip) to re-indent every line in the current paragraph in a single k
category:
editing
tags:
#editing
#indentation
#text-objects
#normal-mode
How do I define a multi-line string in Vimscript without concatenation or escape sequences?
Vim 8.
category:
command-line
tags:
#ex-commands
#config
#macros
How do I move partial command feedback into the statusline instead of the last screen line?
:set showcmdloc=statusline
When you chain operators and motions, showcmd feedback is critical, but the default bottom-line location can fight with command messages and prompts.
category:
command-line
tags:
#command-line
#ui
#statusline
#config
How do I make mksession restore globals and local options too?
:set sessionoptions+=globals,localoptions
If you rely on sessions for context switching, default :mksession can feel incomplete because some state does not come back.
category:
config
tags:
#config
#sessions
#workflow
#state
How do I customize Vim's statusline to show useful file information?
:set statusline=%f\ %y\ [%l/%L]
Vim's statusline option lets you build a custom status bar from format items.
category:
config
tags:
#config
#formatting
How do I make gf find files even when the import path omits the file extension?
:set suffixesadd+=.js,.ts,.py
In many programming languages, import statements reference modules without file extensions (e.
category:
navigation
tags:
#navigation
#config
#editing
How do I create text shortcuts that auto-expand while typing in Vim?
:iabbrev defines insert-mode abbreviations that expand automatically when you type a non-keyword character (space, punctuation, ) after the abbreviation.
category:
config
tags:
#insert-mode
#config
#editing
How do I execute the contents of the system clipboard as a Vim macro?
In Vim, @{register} executes the contents of any register as a macro.
category:
macros
tags:
#macros
#registers
#normal-mode
How do I use an external formatter with the gq operator in Vim?
Vim's gq operator normally reflows text to fit textwidth, but by setting formatprg you can delegate formatting to any external tool — a language formatter, a
category:
config
tags:
#formatting
#config
#editing
#ex-commands
How do I build a location list of TODO matches across a project?
:lvimgrep /\<TODO\>/gj **/* | lopen
If you want project-wide search results without polluting the global quickfix list, use a location list.
category:
search
tags:
#search
#quickfix
#buffers
#windows
#ex-commands
How do I check if a specific Vim feature or capability is available before using it in my vimrc?
The has('feature') function returns 1 if the specified feature is available in the current Vim/Neovim instance, 0 otherwise.
category:
config
tags:
#config
#vimscript
#portability
How do I change existing surrounding quotes to parentheses with vim-surround?
The cs operator in vim-surround (change surrounding) swaps one pair of delimiters for another without touching the content inside.
category:
plugins
tags:
#plugins
#editing
#surround
#text-objects
How do I open the file whose name is under the cursor in a new tab?
gf reads the filename under the cursor and opens it in a new tab page, keeping your current buffer untouched.
category:
navigation
tags:
#navigation
#buffers-windows
#tabs
How do I write a non-greedy (lazy) quantifier in Vim's search regex?
In Vim's regex engine, \{-} is the non-greedy (lazy) quantifier — it matches as few characters as possible, unlike .
category:
search
tags:
#search
#regex
#patterns
#substitution
How do I pass a range of lines through a shell command and replace them?
The :{range}!command syntax pipes the specified lines through an external shell command and replaces them with the output.
category:
command-line
tags:
#command-line
#shell
#filtering
#unix
#ex-commands
How do I insert register contents into the command line?
How it works While typing an Ex command on the command line (after pressing :), you can insert the contents of any register by pressing Ctrl-R followed by the r
category:
registers
tags:
#registers
#ex-commands
#editing