vimtricks.wiki Concise Vim tricks, one at a time.

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

  1. Start a forward search: /
  2. Type a few characters until you see a match highlighted
  3. Press <C-l> to append the next character from the buffer at the match position to the pattern
  4. Repeat <C-l> to keep extending the pattern one character at a time
  5. 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 incsearch to 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

Next

How do I enable matchit so % jumps between if/else/end style pairs?