Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Vim: highlight all matches in incsearch

Tags:

vim

I'm using the incsearch and hlsearch options. All matches are highlighted after I press enter, but only the first one as I type. I'd like to highlight all matches as I type.

How can I get that behavior?

like image 686
slezica Avatar asked May 26 '12 09:05

slezica


2 Answers

You can use the incsearch.vim plugin:

Automatic :nohlsearch

Install with your favourite plugin manager and map your search key(s) to call the plugin's search.

like image 139
Andy Hayden Avatar answered Sep 27 '22 20:09

Andy Hayden


Unfortunately, this isn't possible without writing your own search in Vimscript (capturing each key via getchar(), highlighting via :match), or patching the core Vim source code in C.

The reason this isn't implemented is probably to keep the incsearch snappy and immediate.

Update: Highlighting all matches now is the default behavior starting with Vim 7.4.2259 (with 'incsearch' can only see the next match).

like image 30
Ingo Karkat Avatar answered Sep 27 '22 21:09

Ingo Karkat