How do I extend my incremental search pattern one character at a time from the current match without retyping?
<C-l> during / search
When searching with incsearch enabled, Vim highlights matches as you type.
640 results for "/pattern"
<C-l> during / search
When searching with incsearch enabled, Vim highlights matches as you type.
:keeppatterns {cmd}
Whenever Vim runs a command that involves searching — :g, :s, :v, or even moving the cursor with / — it overwrites the last search register (@/).
\%'m
Vim's \%'m regex atom matches the exact position of mark m in a search pattern.
: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.
macros #macros #automation #search #normal-mode #ex-commands
:e +{line} {file}
The :edit command accepts a +{cmd} prefix that executes an Ex command immediately after the file is loaded.
command-line #buffers #ex-commands #navigation #command-line
\zs and \ze
How it works Vim's \zs (set start) and \ze (set end) atoms let you define which portion of a pattern counts as the actual match, even though the full pattern is
\%(...\)
Vim's standard grouping syntax \(.
:packadd cfilter | Cfilter /ERROR/
Quickfix lists can get noisy in large projects, especially when one grep or compiler run mixes several classes of issues.
/\zs and \ze
The \zs and \ze atoms let you define where the actual match starts and ends within a larger pattern.
/pattern1/;/pattern2/
Vim's search offsets allow chaining two patterns together with a semicolon.
:history /
Power users tend to run long, composable searches during refactors, but the default / and ? history navigation can be noisy when command history and search hist
:call matchadd('ErrorMsg', 'TODO')
matchadd() lets you highlight arbitrary patterns using any highlight group — without touching the search register or search highlighting.
\_.{-}
The \ modifier in Vim extends any character class or atom to also match newlines.
:/start/,/end/ {command}
Vim's range addressing lets you specify a line range using search patterns instead of explicit line numbers.
:pedit +/TODO %
When you need a second read-only view of the same file, opening more normal splits can disrupt your working layout.
/colour\%[s]
Vim's \%[.
:e +{cmd} {file}
The :e +{cmd} {file} form opens a file and executes an Ex command immediately after loading it.
\&
Vim's \& operator is the AND combinator in a search pattern.
:keeppatterns %s/old/new/g
The :keeppatterns modifier runs any Ex command without modifying Vim's last search pattern (stored in @/).
command-line #search #ex-commands #command-line #substitute #registers
:%s/\zsparseData\ze(/processData/g
Vim's \zs and \ze atoms let you include context in your search pattern without including that context in the replacement.