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

How do I move through search matches while still typing the pattern?

Answer

<C-g> and <C-t>

Explanation

While the search prompt is open (with incsearch enabled), pressing <C-g> advances the cursor to the next match and <C-t> moves it to the previous match — all without leaving the search prompt. This lets you visually explore matches and refine your pattern before committing.

How it works

  • <C-g> — jump to the next occurrence of the current pattern (mnemonic: Go forward)
  • <C-t> — jump to the previous occurrence (mnemonic: go back, like Tab order)
  • Both work only while :set incsearch is active (the default in Neovim and Vim 8+)
  • Press <CR> to confirm the search and land on the current match, or <Esc> to cancel

Example

Suppose you have a file with many references to config and you want to land on the third one:

/config

Instead of pressing <CR> and then nn, you stay in the search prompt and press <C-g> twice to move to the third match, then confirm with <CR>. The cursor ends up exactly where you want.

Tips

  • Combine with <C-l> to extend the search pattern one character at a time from the current match, narrowing down results interactively
  • The match count displayed in the status line updates in real time (in Neovim with showcmd enabled)
  • Useful when you want to distinguish between getUser and getUserById — type enough of the pattern, navigate to the right instance, then commit

Next

How do I match a pattern only when it is preceded or followed by another pattern, without including that context in the match?