Vim highlighting with solarized color scheme
Asked Answered
G

1

8

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: White space errors highlighted in red

However, i've recently started using the solarized color scheme and I am not able to get these highlights to display. solarized with no highlights

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
Gownsman answered 7/8, 2012 at 1:18 Comment(4)
Where are you calling the highlight?Backscratcher
In my .vimrc? (not sure if I understand the question)Gownsman
Before or after you call colorscheme solarized?Backscratcher
Before, I think thats it..thanks!Gownsman
W
7

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:

  1. It does not highlight in split windows.
  2. You lose the ability of quickly highlighting custom stuff via :match.

There are several plugins that offer this functionality, in a better way. Mine is called ShowTrailingWhitespace; the plugin page contains links to alternatives.

Witkowski answered 30/10, 2012 at 14:22 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.