skamsie
skamsie

Reputation: 2726

vim highlight found words one by one

In vim I want to highlight the word found when jumping to it. I know about :set hlsearch but that highlights all the words found.

For example I have a buffer:

the cat is fat
the cat is black

I do /cat and now it should highlight 'cat' on the first line. Then if I press n, when the cursor jumps to the 'cat' on the second line it should highlight this one and de-highlight the first one, and so on...

Is there a setting to set in .vimrc to achive this, or a plugin of some sort? I am basically trying to better highlight the found word without highlighting all of them.

Upvotes: 0

Views: 84

Answers (1)

Matthew Strawbridge
Matthew Strawbridge

Reputation: 20600

The Searchant plug-in might do what you need. It lets you set different formatting for the current search result.

Having said that, I find Vim's default behaviour of highlighting all the search results at once very useful; it lets you plan ahead and makes it easy to check that your search term is matching where you expect. Any if the formatting of your cursor contrasts strongly, it's easy to see which is the current result.

Upvotes: 2

Related Questions