vim Searching for the word under the cursor


Example

In normal mode, move the cursor to any word then press * to search forwards for the next occurrence of the word under the cursor, or press # to search backwards.

* or # search for the exact word under the cursor: searching for big would only find big and not bigger.

Under the hood, Vim uses a simple search with word boundaries atoms:

  • /\<big\> for *,
  • ?\<big\> for #.

g* or g# don't search for the exact word under the cursor: searching for big would find bigger.

Under the hood, Vim uses a simple search without word boundaries atoms:

  • /\<big\> for *,
  • ?\<big\> for #.