Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

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?

share|improve this question

2 Answers 2

up vote 4 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

 
discard

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.