Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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.

like image 227
zoltanctoth Avatar asked Nov 08 '11 10:11

zoltanctoth


People also ask

How do I cycle through a search in Vim?

Press Esc to cancel or press Enter to perform the search. Then press n to search forwards for the next occurrence, or N to search backwards. Type ggn to jump to the first match, or GN to jump to the last.

What is Incsearch Vim?

incsearch. vim is a Vim plugin which improve incremental searching. It provides functionality to highlight all matches while searching, to move cursor to next/previous match while searching and so on.


2 Answers

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 '/'.

like image 98
Matthew Walton Avatar answered Sep 22 '22 23:09

Matthew Walton


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

like image 43
Sofronie Cristian Avatar answered Sep 19 '22 23:09

Sofronie Cristian