vim Searching in the current buffer Searching for an arbitrary pattern


Example

Vim's standard search commands are / for forward search and ? for backward search.

To start a search from normal mode:

  1. press /,
  2. type your pattern,
  3. press <CR> to perform the search.

Examples:

/foobar<CR>      search forward for foobar
?foo\/bar<CR>    search backward for foo/bar

n and N can be used to jump to the next and previous occurence:

  • Pressing n after a forward search positions the cursor on the next occurence, forwards.

  • Pressing N after a forward search positions the cursor on the next occurence, backwards.

  • Pressing n after a backward search positions the cursor on the next occurence, backwards.

  • Pressing N after a backward search positions the cursor on the next occurence, forwards.