How do I do a case-preserving search and replace across different naming conventions?
:%Subvert/old{,s}/new{,s}/g
Tim Pope's vim-abolish plugin provides the :Subvert command (aliased as :S), which performs substitutions that automatically preserve case variants and handle p
category:
plugins
tags:
#plugins
#substitution
#editing
#ex-commands
#search
How do I filter the output of an Ex command to show only matching lines?
:filter /pattern/ command
The :filter command restricts the output of another Ex command to only lines matching a given pattern.
category:
command-line
tags:
#ex-commands
#command-line
#search
#buffers
How do I match only part of a search pattern in Vim using \zs and \ze?
Vim's \zs (start of match) and \ze (end of match) atoms let you define a search pattern but only highlight or operate on a portion of it.
category:
search
tags:
#search
#regex
#substitution
#ex-commands
#editing
How do I search for patterns only at specific line or column positions in Vim?
Vim provides position-matching atoms that constrain where a pattern can match based on line numbers, column positions, or virtual columns.
category:
search
tags:
#search
#regex
#position
#columns
How do I search for a pattern repeated an exact number of times in Vim?
Vim supports counted quantifiers that let you specify exactly how many times a pattern should repeat.
category:
search
tags:
#search
#regex
#quantifiers
#patterns
How do I search using lookahead and lookbehind patterns in Vim?
Vim supports zero-width assertions (lookahead and lookbehind) in its regex engine, allowing you to match text based on what precedes or follows it without inclu
category:
search
tags:
#search
#regex
#patterns
#advanced-search
How do I increment or add to all numbers in a file using Vim substitution?
:%s/\d\+/\=submatch(0)+1/g
Vim's expression replacement (\=) in substitutions lets you perform arithmetic on matched text.
category:
search
tags:
#search
#substitute
#arithmetic
#numbers
How do I swap or rearrange text using captured groups in Vim substitution?
:%s/\(\w\+\) \(\w\+\)/\2 \1/g
Vim's substitute command supports captured groups (back-references) using \( and \), allowing you to capture parts of a match and rearrange them in the replacem
category:
search
tags:
#search
#substitute
#regex
#captured-groups
How do I search for non-printable or control characters in Vim?
Files sometimes contain hidden control characters that cause subtle bugs.
category:
search
tags:
#search
#special-characters
#hex
#control-characters
How do I search for a pattern that spans multiple lines in Vim?
Vim's regular expressions support multi-line matching through underscore-prefixed atoms.
category:
search
tags:
#search
#regex
#multiline
#patterns
How do I search for multiple alternative patterns at once in Vim?
Vim's search supports alternation with the \ operator, allowing you to find any one of several patterns in a single search.
category:
search
tags:
#search
#regex
#alternation
#patterns
How do I use POSIX character classes in Vim search patterns?
Vim supports POSIX character classes inside bracket expressions, providing a portable and readable way to match categories of characters.
category:
search
tags:
#search
#regex
#character-classes
#posix
How do I view or manipulate the search pattern register in Vim?
The / register holds the most recent search pattern.
category:
registers
tags:
#registers
#search
#pattern
#special-registers
How do I persistently highlight specific patterns with custom colors in Vim?
:call matchadd('Search', 'pattern')
The matchadd() function lets you add persistent highlights to patterns without affecting the search register.
category:
search
tags:
#search
#highlighting
#matchadd
#advanced-search
How do I use cgn to repeat a change on every search match?
/pattern<CR>cgnreplacement<Esc>.
The gn text object selects the next search match, and cgn changes it.
category:
macros
tags:
#macros
#cgn
#search
#interactive-replace
How do I search across files using the location list instead of quickfix?
While :vimgrep populates the global quickfix list, :lvimgrep uses the window-local location list instead.
category:
search
tags:
#search
#location-list
#vimgrep
#files
How do I create a macro that only acts on lines matching a search pattern?
By starting a macro with a search command, the macro becomes conditional — it jumps to the next match before acting, and terminates when no more matches are f
category:
macros
tags:
#macros
#search
#conditional
#pattern
How do I visually hide or conceal matched text in Vim?
:syntax match Conceal /pattern/ conceal
Vim's conceal feature lets you visually hide text that matches a pattern, or replace it with a single character.
category:
search
tags:
#search
#syntax
#conceal
#display
How do I configure Vim to use ripgrep as its built-in grep program?
:set grepprg=rg\ --vimgrep
Vim's :grep command uses an external program to search files and populate the quickfix list.
category:
config
tags:
#config
#grep
#ripgrep
#search
How do I search and filter through command-line history in Vim?
Vim's command-line history window (q: for Ex commands, q/ for search) opens a full editing buffer containing your history.
category:
command-line
tags:
#command-line
#history
#search
#recall