How do I see search results as I type the pattern?
Answer
:set incsearch
Explanation
The incsearch option enables incremental search, which highlights matches in real time as you type the search pattern. This provides immediate feedback on what your search will match.
How it works
- With
incsearchenabled, Vim highlights the first match as you type each character - The view scrolls to show the current match
- Press
<CR>to confirm or<Esc>to cancel
Example
With incsearch on, typing /func incrementally shows matches:
/fhighlights the firstf/fujumps to the firstfu/funcjumps to the firstfunc
Tips
- This is enabled by default in most Vim configurations
<C-g>and<C-t>jump to the next/previous match while typing- Pairs well with
hlsearchfor complete search visibility - Neovim has
inccommandfor live preview of:substitute