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

How do I find the next occurrence of my search pattern?

Answer

n

Explanation

After performing a search with / or ?, pressing n repeats the search in the same direction to find the next match.

How it works

  • n moves to the next match in the search direction
  • After /, n searches forward; after ?, n searches backward
  • Wraps around the end/beginning of the file

Example

Searching /error finds the first error. Pressing n finds the second, n again finds the third, and so on.

Tips

  • N searches in the opposite direction
  • {count}n jumps ahead by N matches
  • :set hlsearch highlights all matches for easy visibility
  • The search pattern is remembered until you search for something new

Next

How do you yank a single word into a named register?