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 directionN— repeat in the backward direction3njumps to the 3rd next match from the cursor5Njumps 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
Ntoo:3Njumps 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
gnas well:2gnselects the 2nd next match as a text object - If the count exceeds available matches, Vim wraps around (if
wrapscanis set)