15

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?

1

2 Answers 2

10

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".

7
  • Thanks, that's exactly what I needed. I need to play around with colors now :)
    – jordelver
    Apr 13, 2012 at 20:14
  • 1
    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, 2012 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, 2012 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, 2012 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, 2012 at 18:06
7

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

You must log in to answer this question.

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