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

How do I jump to the Nth next search match instead of pressing n repeatedly?

Answer

{count}n

Explanation

Like most Vim motions, the n and N search repeat commands accept a count prefix. Typing 3n skips directly to the 3rd next occurrence of the current search pattern, avoiding the need to press n three times separately. This works in both directions and integrates with the jump list.

How it works

  • {count} — a number typed before the command (e.g., 3, 10)
  • n — repeat the last search in the forward direction
  • N — repeat in the backward direction
  • 3n jumps to the 3rd next match from the cursor
  • 5N jumps to the 5th previous match

Example

Searching for error in a log file with /error<CR> places the cursor on the first match. Instead of pressing n ten times, type 10n to jump immediately to the 10th match from the current position.

Tips

  • The count can be used with N too: 3N jumps 3 matches backward
  • After jumping, the jump list is updated — use <C-o> to return
  • Combine with * or # (search word under cursor) to quickly skip ahead several occurrences
  • Works with gn as well: 2gn selects the 2nd next match as a text object
  • If the count exceeds available matches, Vim wraps around (if wrapscan is set)

Next

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