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.
: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 thenshift+N
to look backwards. And obviously,?
is inverse of/
which starts the search. – Pellicle