How do I use a Vim expression to dynamically compute the replacement in a substitution?
:s/\d\+/\=submatch(0)+1/g
The \= prefix in a :substitute replacement field tells Vim to evaluate the following as a Vimscript expression rather than treating it as a literal string.
category:
registers
tags:
#search
#editing
#ex-commands
#registers
How do I override ignorecase or smartcase for a single search without changing my settings?
Vim's \c and \C flags let you force a search to be case-insensitive or case-sensitive on a per-search basis, regardless of your ignorecase and smartcase setting
category:
search
tags:
#search
#normal-mode
#ex-commands
How do I search for a pattern across all files in my project with Vim's built-in grep?
:vimgrep /pattern/ (shortened to :vim) is Vim's built-in project-wide search.
category:
command-line
tags:
#search
#ex-commands
#navigation
#command-line
How do I run a substitution only within the exact characters of my visual selection?
:%s/\%Vpattern/replacement/g
The \%V atom restricts a regex match to the last visual selection — more precisely than :'s/.
category:
search
tags:
#search
#visual-mode
#ex-commands
#normal-mode
How do I temporarily highlight a custom text pattern in my buffer without changing the syntax file?
:match {group} /{pattern}/
:match lets you apply a highlight group to any pattern in the current window without touching the buffer or its syntax rules.
category:
config
tags:
#search
#config
#normal-mode
#ex-commands
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
How do I use a VimScript expression as the replacement in a substitution?
:s/pattern/\=expression/g
Prefixing the replacement string with \= in a :substitute command tells Vim to evaluate the rest as a VimScript expression rather than literal text.
category:
search
tags:
#search
#ex-commands
#editing
#normal-mode
How do I view my complete Vim command and search history?
:history displays a numbered list of your recently entered Ex commands, giving you a full audit of what you have run in the current session (and across sessions
category:
command-line
tags:
#ex-commands
#command-line
#search
How do I insert a newline in the replacement string of a :s substitution?
In Vim's :substitute command, \r in the replacement string inserts a literal newline — it splits the line at that point.
category:
search
tags:
#search
#editing
#ex-commands
#normal-mode
How do I run a substitution or command on every line in the quickfix list?
:cdo {cmd} executes {cmd} on each entry in the quickfix list — one by one, jumping to each location in turn.
category:
command-line
tags:
#ex-commands
#quickfix
#search
#editing
#buffers
How do I split a line by inserting a newline with the substitute command?
In Vim's substitute command, use \r (not \n) in the replacement to insert a real newline.
category:
editing
tags:
#editing
#search
#ex-commands
#substitution
How do I force a case-sensitive or case-insensitive search for just one pattern without changing my settings?
Vim's \C and \c atoms let you override ignorecase and smartcase on a per-pattern basis.
category:
search
tags:
#search
#normal-mode
#ex-commands
How do I count the number of pattern matches in a file without making substitutions?
The :s///gn command counts how many times a pattern appears in the file without actually replacing anything.
category:
command-line
tags:
#search
#ex-commands
#substitution
#command-line
How do I search for a pattern across all files in my project without leaving Vim?
:vimgrep /pattern/ searches recursively through all files in the current working directory tree using Vim's own regex engine, populating the quickfix list with
category:
search
tags:
#search
#quickfix
#ex-commands
#navigation
How do I search for a pattern only on a specific line number or at a specific column position?
Vim's \%l and \%c pattern atoms anchor a search to a particular line number or column, enabling surgical searches and substitutions that standard regex cannot e
category:
search
tags:
#search
#regex
#ex-commands
How do I run a command on every individual quickfix entry in Vim?
:cdo {cmd} executes a command at every entry in the quickfix list, visiting each location in turn.
category:
command-line
tags:
#command-line
#ex-commands
#search
#editing
How do I move through search matches while still typing the pattern?
While the search prompt is open (with incsearch enabled), pressing advances the cursor to the next match and moves it to the previous match — all without leav
category:
search
tags:
#search
#incsearch
#navigation
How do I uppercase or lowercase matched text directly in a substitute command?
Vim's substitute replacement string supports special case-transform atoms that change the case of matched text without requiring a second pass or an external to
category:
editing
tags:
#editing
#search
#ex-commands
#formatting
How do I match a pattern only when followed or preceded by another pattern in Vim?
\@= and \@! and \@<= and \@<!
Vim's regex engine supports zero-width lookahead and lookbehind assertions using the \@=, \@!, \@<=, and \@<! atoms.
category:
search
tags:
#search
#regex
#normal-mode
How do I search for the word under the cursor as a substring, not a whole word?
The and # commands search for the exact whole word under the cursor (with word boundaries \).
category:
search
tags:
#search
#navigation
#normal-mode