How do I paste or reuse my last search pattern?
<C-r>/
Vim stores your last search pattern in the / register.
640 results for "/pattern"
<C-r>/
Vim stores your last search pattern in the / register.
:g//d
:g//d uses an empty pattern in the global command, which instructs Vim to reuse the last search pattern.
/pattern/e+1<CR>
Most Vim searches place the cursor at the start of the match.
/pattern/;+3
In Vim's range notation, a semicolon (;) between two addresses makes the second address relative to the line the first address matched, not to the current curso
:vimgrep // **/*.txt
Using // (an empty pattern) in :vimgrep tells Vim to reuse the last search pattern.
\@=
Vim's regex engine supports zero-width lookahead and lookbehind assertions using the \@ family of atoms.
"/p
Vim stores the last search pattern in the search register "/.
:g/pattern/yank A
The :g command combined with yank A (uppercase A to append) lets you collect every line matching a pattern into a single register without overwriting previous c
command-line #editing #ex-commands #global-command #registers #filtering
:g/outer/,/end/g/inner/
The :global command accepts a range, which lets you scope its search to sections of the file rather than the entire buffer.
: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.
:'<,'>g/pattern/command
How it works The :g (global) command is one of Vim's most powerful features.
:sort /pattern/
The :sort /{pattern}/ command sorts lines by their content after the first match of the pattern.
/pattern<CR>cgnreplacement<Esc>.
The gn text object selects the next search match, and cgn changes it.
/pattern/+3
Vim's search command accepts an offset after the pattern that shifts where the cursor lands relative to the match.
?pattern
The ?pattern command searches backward through the file for the given pattern, starting from the cursor position and wrapping around to the end of the file if n
:lvimgrep /pattern/ %
While :vimgrep populates the global quickfix list, :lvimgrep uses the window-local location list instead.
:%s/pattern/\=@0/g
The \=@0 replacement expression inserts the contents of register 0 (last yank) as the replacement text.
:vimgrep /pattern/g **/*.ext
The :vimgrep command searches for a pattern across multiple files and loads the results into the quickfix list.
qq /pattern<CR> {commands} q
By incorporating a search command inside a macro, you can make it jump to the next occurrence of a pattern before performing its edits.
:let @a = @/
Vim stores the last search pattern in the special / register (@/).