Wiki

by yszheda

View project onGitHub

Tip 79: Meet the Search Command

Return to the top: <<Practical Vim>>

Execute a Search

If you ever need to search from the current cursor position to the end of the document without wrapping around, you can disable the 'wrapscan' option.

References:

# If you open the file in vim,
# then you can \"ayy@a the next line to execute the vim command: 
:h 'wrapscan'

Specify the Search Direction

Repeat the Last Search

  • The n command preserves the direction as well as any offsets that were applied to the previous search.
  • The N command always goes in the opposite direction from the last search.
Command Effect
n Jump to next match, preserving direction and offset
N Jump to previous match, preserving direction and offset
/<CR> Jump forward to next match of same pattern
?<CR> Jump backward to previous match of same pattern

Recall Historical Searches

When the search prompt is visible, we can scroll through the previous searches by pressing the <Up> key.