Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

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?

share|improve this question
    
Your .vimrc isn't in the repository, nor ./rc.local/. Check if you set any guioptions after sourcing appearance. –  Sukminder May 5 '13 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. –  Murali Suriar May 5 '13 at 15:10
    
OK. Thanks for explanation. Makes sense now ;) –  Sukminder May 5 '13 at 17:44
add comment

1 Answer

up vote 1 down vote accepted

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
endif

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.

I.e.:

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

  for f in split(glob ...

Another way would be to load custom highlight on BufLoad.

Etc. …

share|improve this answer
    
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? –  Murali Suriar May 6 '13 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. –  Sukminder May 6 '13 at 19:42
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.