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

How do I search forward for text in Vim?

Answer

/{pattern}

Explanation

The / command initiates a forward search in the file. Type your search term and press Enter to find the first match after the cursor.

How it works

  • Press / to open the search prompt at the bottom
  • Type your search pattern
  • Press <CR> (Enter) to execute the search
  • The cursor jumps to the first match

Example

The quick brown fox jumps over the lazy dog

Typing /fox<CR> moves the cursor to fox.

Tips

  • n finds the next match in the same direction
  • N finds the next match in the opposite direction
  • / wraps around the end of the file by default
  • :set nowrapscan disables wrap-around searching

Next

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