简体   繁体   中英

Make Vim highlight all search results while typing the search and turn off highlighting when I do anything else

I would like my Vim to highlight all search results as I am typing my search, ie not just the next search result (as in incsearch ), but all of them (as in hlsearch but at the same time as I am typing). I would also like to turn off search highlighting as soon as I do anything else than search. Is this possible?

It sounds like you want haya14busa/incsearch.vim . The biggest thing it does is highlighting every result as you are searching, which you can see in this gif:

在此输入图像描述

There are other things it does too. For example, it can be configured to turn of highlighting when you are done searching, and it can also provide useful mappings for other search related features, like

n  
N  
*  
#  
g* 
g# 

You can install it with Neobundle/Vundle/vim-plug by doing

NeoBundle 'haya14busa/incsearch.vim'
Plugin 'haya14busa/incsearch.vim'
Plug 'haya14busa/incsearch.vim'

or with pathogen by doing:

git clone https://github.com/haya14busa/incsearch.vim ~/.vim/bundle/incsearch.vim

You could try the vim-cool plugin, which was mentioned in a similar question :

Vim-cool disables search highlighting when you are done searching and re-enables it when you search again.

Vim-cool re-enables search highlighting when the cursor is on a word that matches the last search pattern.

Vim-cool is cool.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM