Question

In Vimperator, press / and do a search. If there are matches, all will be highlighted.

My question is how to clean these highlights in a decent way.

My current approach is to press / again, and type in a random string like "abcdefgh", enter, and press Esc to clean the red warning in command window.

Was it helpful?

Solution 2

The :nohlsearch command will remove the search highlights. You could map this to a key if you use it frequently.

OTHER TIPS

Type the following to quickly clear highlighted text

:noh

or you can toggle it highlight with

:set hls!

Remaping is awesome and you should do it!

To add to the answers above:
You can remap some of the keys to handle this automatically for you.
e.g. put this to your ~/.vimperatorrc

" adjust search to enable highlight when searching and disable when escape is pressed
noremap n :set hlsearch<return>n
noremap <esc> :noh<return><esc>

Explanation:
noremap - remaps a key sequence without remaping keys.
n key to remap.
:set hlsearch<return>n function we want remap to perform in this case enable highlighting.

This will set highlight on when you click n (for the next search result) and turn it off when you click escape. You can also use / instead of n if you want highlight on when you start search instantly.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top