6

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.

Mehrad
  • 3,805
  • 3
  • 35
  • 57
Vin
  • 497
  • 2
  • 16

3 Answers3

9

Type the following to quickly clear highlighted text

:noh

or you can toggle it highlight with

:set hls!

William
  • 944
  • 8
  • 13
  • I combined this with other answers by remapping it and storing it in the config file. For other newbs, here are the steps (Ubuntu): 1) `:mkv` to make the `~/.vimperatorcc` file. 2) Edit that file in editor of choice (e.g. vim or nano), adding the following: `map ? :noh`. I also added a comment above it to explain it: `" Remap ? from 'Search backwards' to 'clear find highlights'`. I chose `?` because I just don't use "search backwards". I just search and then `shift+N` to look backwards. And obviously, `?` is inverse of `/` which starts the search. –  Jun 24 '16 at 12:45
7

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

Richard Neish
  • 7,053
  • 4
  • 32
  • 65
2

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.

Granitosaurus
  • 17,068
  • 2
  • 45
  • 66