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?

  • Your .vimrc isn't in the repository, nor ./rc.local/. Check if you set any guioptions after sourcing appearance.
    – Runium
    May 5, 2013 at 14:37
  • @Sukminder rc.local doesn't exist in the repository deliberately; it's for things that I want to configure which shouldn't be in version control. .vimrc is called 'vimrc' in the root of the directory I linked. I leave the trailing . off so that the file isn't hidden; I create a symlink when I actually install it. May 5, 2013 at 15:10
  • OK. Thanks for explanation. Makes sense now ;)
    – Runium
    May 5, 2013 at 17:44

2 Answers 2


The issue is caused by the sensible plugin:line 93. :help t_Co

" Allow color schemes to do bright colors without forcing bold.
if &t_Co == 8 && $TERM !~# '^linux'
  set t_Co=16  " << --- Causes hickup

If you run vim in verbose log mode (vim -V15load_log.vim) – and search for t_Co= and RedundantSpaces you'll see that sensible is actually parsed after your appearance.vim file.

Quick fix would be to either comment out that section of the code and add it to your .vimrc, but as you link to git repositories that is perhaps not what you want.

A different approach would be to move it out of the bundledirectory and add it as a separate source line in your vimrc, before your glob loop.


  source ~/.vim/hacks/vim-sensible/plugin/sensible.vim

  for f in split(glob ...

Another way would be to load custom highlight on BufLoad.

Etc. …

  • Excellent, thanks. So, my next question - why is sensible.vim parsed after my glob loop? Does that mean that any plugins managed by pathogen are actually set up after my .vimrc has been processed? May 6, 2013 at 0:27
  • Good question. I haven't looked to deep at pathogen and load routine. It could be the load sequence of vim itself as well. Best bet is to run with various verbose levels and look et logs. Or try benchmark debug.
    – Runium
    May 6, 2013 at 19:42

If you're using NeoBundle then using NeoBundleLazy 'tpope/vim-sensible', then NeoBundleSource at the end of your vimrc does the trick. Also see https://github.com/tpope/vim-sensible/issues/74.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .