Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

When I do search in gVim (package gnome-vim), the search results are highlighted. How can I turn-off this highlighting when I don't need it any longer? Now it looks like persistent.

share|improve this question
up vote 3 down vote accepted

You can disable search results highlighting by command :nohl. If you want to have this command under one keystroke, put the following lines into your ~/.vimrc configuration file:

" press F8 to turn the search results highlight off
noremap <F8> :nohl<CR>
inoremap <F8> <C-o>:nohl<CR>

Now you can press F8 to toggle search result highlighting on and off in both edit and insert mode.

share|improve this answer
+1, but wouldn't inoremap <F8> <C-o>:nohl<CR> be better? So it will leave you in the same input mode where you were... – Rmano Aug 7 '14 at 11:36
@Rmano please explain. My solution (it is taken from my own ~/.vimrc) doesn't change the editor mode. – user280493 Aug 7 '14 at 11:45
CTRL-o is the command to enter in normal mode for just one command, and then go back to input. In your macro, you exit input mode, and the you do an "append". So for example if you are inserting before the first caracter of a line (go to the start of the line and press "i"), with your macro after pressing F8 you will be inserting after the first character of the row (the result of "a"). With my version you will just continue inserting before or after, whatever you were doing before pressing F8. – Rmano Aug 7 '14 at 11:53
@Rmano You are right, I just tried your 'test scenario' and it works like you said. Thanks for pointing this out, I will update my ~/.vimrc as well as my answer here. – user280493 Aug 7 '14 at 11:58
For the record this cannot turn highlighting back on. This only turns highlighting off (temporarily). The next search will highlight again automatically though. – Etan Reisner Aug 7 '14 at 15:06

You can edit your .vimrc file :

To disable the highlighting temporarily, write :set nohlsearch and delete :set hlsearch

Then save and exit .

share|improve this answer
This is a valid answer, although it's a bit roundabout. – TankorSmash Aug 7 '14 at 14:44

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.