Word Search

* / # โ€” search for the word under the cursor without typing it.

Keys: *, #, g*, g#

Put the cursor on a word, press * to search forward for the next occurrence, # for the previous. g* and g# do the same but without word boundaries.

Cursor on a word, press *, jump to the next occurrence. Press #, jump to the previous. No typing the pattern, no closing Enter.

Next occurrence of word under cursor
KeyNote
*
Previous occurrence of word under cursor
KeyNote
#
Next, but no word boundaries
KeyNote
g
*
Previous, but no word boundaries
KeyNote
g
#
* โ€” find next occurrence
# โ€” find previous occurrence

Reference

Key Pattern built Direction
* \<word\> Forward
# \<word\> Backward
g* word Forward
g# word Backward

Worked example โ€” * on a word

Search for the current word, no typing required.

Step 1 ยท Cursor on second 'foo'.
Cursor on second 'foo'.
Step 2 ยท * ยท * โ€” searched for \<foo\>; jumped to the next.
* โ€” searched for \<foo\>; jumped to the next.

* turns the cursor word into a search pattern with word boundaries (\<...\>) so 'foobar' won't match. # is the same backward.

See also: Pattern Search, The Replace Loop โ€” *, cw, then . . ., Change-Next-Match Loop โ€” cgn