machakann / vim-highlightedyank

Make the yanked region apparent!
844 stars 22 forks source link

highlighted yank does not work for some color scheme? #36

Closed jdhao closed 6 years ago

jdhao commented 6 years ago

I found that for some colorscheme, highlighted yank does not work. If I use vim-sublime-monokai, the highlight does not work. If I change the colorscheme to gruvbox, now the highlight works.

Settings for highlightedyank is:

hi HighlightedyankRegion cterm=reverse gui=reverse
let g:highlightedyank_highlight_duration = 500
machakann commented 6 years ago

vim-highlightedyank uses IncSearch highlight group by default. However it seems vim-sublime-monokai doesn't set the IncSearch group. Probably that's why the reason. I think the easiest solution is to add the following lines into your vimrc:

augroup vimrc-highlightedyank
  autocmd ColorScheme sublimemonokai highlight HighlightedyankRegion ctermbg=237 guibg=#41423a
augroup END

Please change augroup name and the colors as you prefer.

machakann commented 6 years ago

By the way, in my case vim-highlightedyank just worked with the line:

hi HighlightedyankRegion cterm=reverse gui=reverse

You may need to check whether the setting is really taking effect, for example, type :verbose hi HighlightedyankRegion<CR>. I guess HighlightedyankRegion may be cleared or overwritten somewhere. Locating the line after :colorscheme setting in vimrc may help.

jdhao commented 6 years ago

Thanks, it works now. For anyone interested, you can find the supported color using the script here.