Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

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

After performing a search and replace, my installation of GVIM highlights any text remaining that still matches the search pattern.

Example input text:


I run :%s/foo/bar/gc and confirm that I only wish to replace one foo. The other foo remains highlighted.

Can this be disabled?

share|improve this question
up vote 5 down vote accepted

To completely disable highlighting of searches you can add set nohls to your .vimrc.

share|improve this answer

One cool trick that I have found, which un-highlights your previous search as opposed to completely disabling search highlighting altogether, is to put the following line in your .vimrc file:

:noremap <silent> <Space> :silent noh<Bar>echo<CR>

Now, pressing the spacebar will simply un-highlight the previous search. That way the next time you search something the highlight will appear again. So, in your case after you confirm that you only want to replace one instance of foo, simply press the spacebar and be on your merry way.

share|improve this answer

Your Answer


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

Not the answer you're looking for? Browse other questions tagged or ask your own question.