VIM, incremental search: How can I jump to the next result and get it highlighted?

SearchVimHotkeys

Search Problem Overview


When using VIM's incremental search option I usually search and after I got to the first result (it will be highlighted) I use the / key to jump to the next result.

But:

  1. For this I need to 'cancel' my search and go back to Normal Mode in order to jump the next result.
  2. Pressing / makes VIM jump to the next result but it won't highlight it.

I am wondering if there is a more efficient way to jump between the results using incremental search and get them highlighted.

Search Solutions


Solution 1 - Search

The customary key for jumping to the next search result is 'n'.

I'm not entirely sure what you mean about highlighting - all search results should be highlighted if hlsearch is set, and for me it makes no difference if I go to the next result with 'n' or with '/'.

Solution 2 - Search

With Ctrl-t and Ctrl-g you can move between matches without leaving the search mode

Solution 3 - Search

If you want to highlight all search hits you should set hlsearch not incsearch.

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionzoltanctothView Question on Stackoverflow
Solution 1 - SearchMatthew WaltonView Answer on Stackoverflow
Solution 2 - SearchSofronie CristianView Answer on Stackoverflow
Solution 3 - SearchBenoitView Answer on Stackoverflow