8

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

Example input text:

foo
foo
fighters

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?

4

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

14

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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