How do I see the search match count in the statusline?
:set shortmess-=S
The shortmess option controls which messages are shortened.
:set shortmess-=S
The shortmess option controls which messages are shortened.
:vimgrep /pattern/ **/*.ext
The :vimgrep command searches for a pattern across multiple files and populates the quickfix list with the results.
/\_.pattern
The \.
:grep pattern files
The :grep command runs an external grep tool and loads the results into Vim's quickfix list.
y/<C-r>"<CR>
To search for the exact text you have selected in visual mode, yank it and paste it into the search prompt.
/\<word\>
The \ atoms create word boundaries in a search pattern, matching only complete words and not substrings within larger words.
/\v pattern
The \v flag enables "very magic" mode in Vim regex, where most special characters work like standard regular expressions without needing backslashes.
:%s/\(group\)/\1/g
Capture groups in Vim substitute let you match parts of a pattern and reuse them in the replacement.
:'<,'>s/old/new/g
After making a visual selection, you can run a substitute command that only affects the selected text.
:%s/pattern/\r/g
In the replacement part of :s, \r inserts a newline.
:%s/\(\w\+\)/\u\1/g
Vim provides case-conversion atoms in substitute replacements: \u uppercases the next character, \l lowercases it, \U uppercases until \e, and \L lowercases unt
n
After performing a search with / or ?, pressing n repeats the search in the same direction to find the next match.
/pattern\n next-line
Using \n in a Vim search pattern matches a newline character, allowing you to find patterns that cross line boundaries.
/pattern\@!
The \@! atom is a negative lookahead in Vim regex.
\@<=pattern
The \@<= atom is a positive lookbehind in Vim regex.
/pattern\ze followed
The \ze atom marks the end of the match, so you can match a pattern only when it appears before specific text.
:[{,]}s/old/new/g
By using the range [{,]}, you can limit a substitute command to the lines between the enclosing braces — effectively the current function or block.
:set hlsearch
The hlsearch option highlights all matches of the current search pattern throughout the file, making it easy to see where matches occur.
/{pattern}
The / command initiates a forward search in the file.
?{pattern}
The ? command searches backward from the cursor position.