I just search a text by /text
but cannot close the mode to get away the highlight on the words. What command works in that way.
Asked
Active
Viewed 145 times
0

erogol
- 13,156
- 33
- 101
- 155
-
`:noh` will switch the highlighting off. You can map it to something like `
– Michael Berkowski Aug 20 '13 at 16:15` to quickly get rid of it. -
I end up typing `/xx` or something quick and stupid that it won't find lol. `:noh` is faster if you need a lot of x's. I like the idea of mapping a key to `:noh`. – lurker Aug 20 '13 at 16:16
-
@mbratch `/xx` may clear the hl, but it will be saved in register. should be careful to do something like `:s//bar/g`. – Kent Aug 20 '13 at 16:19
-
@Kent, yeah good advice. I'll probably switch over to the key map you suggested anyway, now that I'm aware of it. I guess I was always too lazy or in a hurry to look up the proper command. – lurker Aug 20 '13 at 16:21
3 Answers
1
:noh
(:nohlsearch
) will clear the highlighting from the search result.
I have
nnoremap <silent> <F2> :noh<cr>
in my vimrc, so that I can just press F2 to clear the highlighting.
if you want to disable highlighting on search, you could just set nohlsearch
.

Rory O'Kane
- 29,210
- 11
- 96
- 131

Kent
- 189,393
- 32
- 233
- 301
-
As well as having a mapping for `:nohl`, I use the plugin [“unimpaired.vim”](https://github.com/tpope/vim-unimpaired), which lets me press `coh` to easily “change option hlsearch” (toggle highlighting for all future searches). – Rory O'Kane Aug 20 '13 at 16:47
0
I have been using this in my.vimrc
so hitting enter removes the highlighting.
nnoremap <CR> :noh<CR><CR>

A.E. Drew
- 2,097
- 1
- 16
- 24