# Searching in Vim

You can search for the word under the cursor using * and # in the forward and reverse directions, respectively. This is synonymous with pressing / and then the word, flanked by \< and \> (which are word boundaries).

# Special chars

Other valid special characters are available:

  • \< - represents the beginning of a word
  • \> - represents the end of a word
  • \w - word character
  • \+ - one or more
  • \s - space or tab
  • \_s - space, tab or newline
  • \(...\) - search group
  • \| - or

# Add modes after search query

Vim also allows special chars that specify modes:

  • /e - positions the cursor after the query instead of at start
  • \c - forces case-insensitive
  • \C - forces case-SENSITIVE

# Options

The options most relevant to searching are:

  • :set incsearch - move the cursor to the matched string as you type
  • :set hlsearch - highlight all search matches, to temporarily disable for current search :noh