I have a vim highlight to display whitespace errors in code:
" Highlight redundant whitespaces and tabs.
highlight RedundantSpaces ctermbg=red
match RedundantSpaces /\s\+$\| \+\ze\t\|\t/
Which displays trailing whitespace problems like this:
However, i've recently started using the solarized color scheme and I am not able to get these highlights to display.
I've tried changing the color names to no avail. The relevant part of my (simple) .vimrc says:
syntax enable
set background=dark
colorscheme solarized
You can change color schemes at anytime in vi by typing colorscheme followed by a space and the name of the color scheme. For more color schemes, you can browse this library on the vim website. You can enable or disable colors by simply typing "syntax on" or "syntax off" in vi.
Solarized is a 16-color palette with unique RGB values. 256-color terminal emulators have more colors than the ANSI palette but completely different RGB values.
Vim color schemes are stored in vim directory named /usr/share/vim/vim80/colors/ but vim80 can be different according to vim version.
After typing the command, press “Tab”. This will open a list of all the available color schemes. If you keep pressing “Tab”, Vim will cycle through all of them.
Moving the :highlight
after the :colorscheme
still doesn't help you when you switch colorschemes in the Vim session.
For that to work, re-define your highlighting via the ColorScheme
event:
autocmd ColorScheme * highlight RedundantSpaces ctermbg=red
BTW, your minimalistic solution has other problems:
:match
.There are several plugins that offer this functionality, in a better way. Mine is called ShowTrailingWhitespace; the plugin page contains links to alternatives.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With