delirium
delirium

Reputation: 918

Vim Visual Mode preserve syntax highlight of selected text

How do I preserve language-specific syntax highlighting in vim visual mode? I would like to change only the background and preserve the text original color when selecting text for editing (e.g. copy/paste). I also would like to do this in vim diff color scheme.

I have played with highlight Visual command but it always ends up overwriting the text syntax highlighting.

I am using vim version 8.1 (2018 May 18) and Amix .vimrc. His configuration setup contains a my_configs.vim file in which I am trying to add my modifications (e.g., hi Visual).

Upvotes: 1

Views: 935

Answers (2)

delirium
delirium

Reputation: 918

What I was looking for is:

hi! Visual cterm=none ctermfg=none ctermbg=242

It was pretty foolish of my part, but I was missing the ctermfg=none part to overwrite (I believe) any configuration set by Amix vim setup. For his setup, if you don't set this property the text color will change in visual mode. I believe you could use gui, guibg and guifg analogously.

Upvotes: 1

Kent
Kent

Reputation: 195129

give this a try:

hi! Visual term=reverse ctermbg=242 guibg=DarkGrey

An advice: do NOT use any "vim distributions" or "Ultimate vimrcs"

Upvotes: 3

Related Questions