How to clean Vimperator search highlights
Asked Answered
T

3

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.

Theobald answered 25/10, 2013 at 17:14 Comment(0)
D
7

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

Delafuente answered 30/10, 2013 at 16:14 Comment(0)
A
9

Type the following to quickly clear highlighted text

:noh

or you can toggle it highlight with

:set hls!

Albina answered 25/12, 2013 at 12:8 Comment(1)
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<CR>. 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.Pellicle
D
7

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

Delafuente answered 30/10, 2013 at 16:14 Comment(0)
A
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.

Actiniform answered 9/2, 2016 at 13:23 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.