I was cleaning up my vimrc today, splitting it into separate files to make it easier to maintain. On completion of these changes, all my configuration, mappings and plugins appear to be working, except for highlighting trailing whitespace.
I have the following lines in .vim/rc/appearance.vim:
highlight RedundantSpaces term=standout ctermbg=red guibg=red
match RedundantSpaces /\s\+$\| \+\ze\t/ "\ze sets end of match so only spaces highlighted
As I understand it, the first line creates a highlight group 'RedundantSpaces', and instructs vim to make the background of any text matching the highlight group red, when on a colour terminal. The second line defines the pattern used to identify text matching the highlight group.
When I open a file in vim and start typing spaces on a blank line, they are not highlighted in red. If I run :source ~/.vimrc
, the highlighting appears.
If I remove the lines sourcing all my individual rc/*.vim
files from .vimrc
and put the above two RedundantSpaces
lines in .vimrc
directly, vim behaves as expected, and trailing whitespace is highlighted.
However, if I leave in the lines sourcing rc/*.vim
, and then have the RedundantSpaces
lines at the end of my .vimrc
(i.e. those commands are the last to be run when vim is invoked), the highlighting still does not work, and I need to source ~/.vimrc
.
It seems clear that something in my rc/*.vim
files is interacting poorly with the highlighting configuration, however I'm at a loss to explain what that is. Nothing in any of those files should be interacting with the highlight configuration.
Can anyone suggest what might be going wrong here?
.vimrc
isn't in the repository, nor./rc.local/
. Check if you set anyguioptions
after sourcingappearance
.