How do I extend my incremental search pattern one character at a time from the current match without retyping?
Answer
<C-l> during / search
Explanation
When searching with incsearch enabled, Vim highlights matches as you type. Pressing <C-l> while the search prompt is open appends the next character from the currently highlighted match to your search pattern. This lets you narrow down ambiguous matches by typing only a few characters and then repeatedly pressing <C-l> to absorb more of the visible text — without lifting your hands to find the exact characters to type.
How it works
- Start a forward search:
/ - Type a few characters until you see a match highlighted
- Press
<C-l>to append the next character from the buffer at the match position to the pattern - Repeat
<C-l>to keep extending the pattern one character at a time - Press
<CR>to confirm and jump to the match
Each <C-l> press moves the end of the pattern one character further into the matched text, making the search progressively more specific.
Example
Buffer contains:
fn process_user_data(input: &str) -> Result<(), Error> {
fn process_payment_data(val: u64) -> Option<u64> {
Typing /process highlights both lines. Instead of typing _user, press <C-l> four times to progressively extend the pattern:
/process_
/process_u
/process_us
/process_use
Now only the first line matches. Press <CR> to jump.
Tips
- Requires
:set incsearchto be active (enabled by default in modern Vim/Neovim) - Works with backward search
?too - Pair with
<C-g>and<C-t>to move between matches while still in the search prompt - Particularly useful when you're not sure of the exact spelling or when the word contains special characters that would need escaping