Super User is a question and answer site for computer enthusiasts and power users. 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

I have changed my Vim colours so when I do a /search, every match is highlighted in bright yellow. This makes matches much easier to see.

However, when I perform a substitution with the confirm flag like :%s/find/replace/gc all the items are highlighted in yellow, which is fine, but I can't tell which item Vim is asking me to confirm.

How can I highlight the current substitution item in another colour so I can see what needs confirming?

share|improve this question
See… . – Daniel Andersson Apr 13 '12 at 15:57
Thanks, that was helpful :) – jordelver Apr 13 '12 at 21:52
up vote 3 down vote accepted

The highlight group you want is "IncSearch" even if you don't have the the 'incsearch' option enabled—it is also used for the current substitution when confirmation is enabled.

See ":help hl-IncSearch".

share|improve this answer
Thanks, that's exactly what I needed. I need to play around with colors now :) – jordelver Apr 13 '12 at 20:14
Follow up question. Is it possible to highlight matches when going through each one with n and N when just searching normally? – jordelver Apr 13 '12 at 20:46
I'm assuming you don't mean just enabling 'hlsearch'? I don't think the "current" match can be highlighted different than all matches, but I haven't needed it since the cursor moves to the current match with n/N. – Heptite Apr 13 '12 at 22:54
Sorry, wasn't clear. I've set different colours for IncSearch and Search. When I /searchterm, the match is highlighted in the IncSearch colour. When I hit enter so I can press n to jump to each match, all matches turn to the Search colour. What I want is to change the colour of each match as I jump to it. Does that make sense? :) This is what happens now with :%s/find/replace/gc. Each match is highighted a different colour as I press y or n. – jordelver Apr 14 '12 at 9:04
Yeah, like I said, there's no option to do this. I don't think it is considered necessary since the cursor is supposed to be on the current match in this context, and that should be a fairly clear indicator. – Heptite Apr 14 '12 at 18:06

When inside vim you can use the command mode:
:highlight IncSearch guibg=green ctermbg=green term=underline

To have it always, put this into your .vimrc:
highlight IncSearch guibg=green ctermbg=green term=underline

share|improve this answer

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .