onehalf
onehalf copied to clipboard
Search and IncSearch have same highlight colors in vim
doing an incremental search for a string or having search highlighting on and doing a search and replace in vim is really cumbersome due to current highlighting colors being used.
when you invoke search in vim all matches for the search pattern are highlighted, then the currently active match is usually highlighted in a different color. In OneHalf however this is not the case:
This results in the following behaviour:
here we can't determine what highlighted instance would be replaced if I press yes.
The next screenshot shows what the behaviour is if IncSearch has a different highlighting then default Search:
In this case I simply hijack the highlighting groups that are defined in the onehalf colorscheme file by linking Search to Pmenu and IncSearch to PMenuSel. like this:
hi! link Search PMenu
hi! link IncSearch PMenuSel
as you can see the current active item is highlighted with a blue background and the others are highlighted with gray.
This is just a hack in my own vim configuration file however, I'm not sure what colors we want to use here. Just putting this out to see how we can fix this.
Indeed fixing this issue is just a matter of changing two lines for Search
and IncSearch
. As for the colors I originally wanted to keep the yellow as they pop more on the screen.
From the top of my head maybe we can try
- white/blue for dark and black/blue for light
- yellow/red
- yellow/blue
- ??
Chrome uses yellow and orange for search highlighting so maybe yellow/red will be a good combination?
To test the colors in onehalfdark.vim
and onehalflight.vim
just replace these lines
call s:h("IncSearch", s:bg, s:yellow, "")
call s:h("Search", s:bg, s:yellow, "")
with
call s:h("IncSearch", s:bg, s:red, "")
call s:h("Search", s:bg, s:yellow, "")
Yellow/red sounds good, even if change our mind later, it's better to be functional for the time being.