2

I have some various configurations in my ~/.vimrc that does things like highlight whitespace issues, etc. When I create a new tab via :tabe <file_name>, the subsequent tab loses all of this. I can :so $MYVIMRC to cause it to load but that's obviously not ideal. Any idea why this is happening or how I can cause it to load when creating new tabs?

Edit: Here's my .vimrc

JamesB41
  • 693
  • 10
  • 20
  • 7
    The functionality you're asking for doesn't make sense: a vimrc file is supposed to be loaded only once per session. If your vimrc does filetype-specific settings for the current buffer, try moving these into a filetype plugin. See `:h ftplugin` and `:h after`. – glts Feb 05 '13 at 19:21
  • That makes sense. I'm just trying to do something like this (filetype agnostic): highlight ExtraWhitespace ctermbg=yellow guibg=yellow match ExtraWhitespace /\s\+$/ – JamesB41 Feb 05 '13 at 19:37
  • 1
    Please, post the content of your `~/.vimrc`. – romainl Feb 05 '13 at 20:12
  • Edited in to the original. Thanks for taking a look at it! – JamesB41 Feb 05 '13 at 20:56
  • Is it problem with highlighting whitespaces and tabs? I have a solution that works also in tabs (and possibility to turn off/on locally for each tab/window). And it should be `syntax match ...` if you want to use that, not only `match ...` I think. – 244an Feb 05 '13 at 21:07
  • Yeah, that's the issue I'm struggling with more than anything. The colors don't seem to load either. I modified it by prepending "syntax" to the match lines and it didn't seem to have any effect. – JamesB41 Feb 05 '13 at 21:15
  • 2
    What version of vim? if you can use `matchadd()` I can post a suggestion. – 244an Feb 05 '13 at 21:17
  • 2
    @JamesB41 Your question is actually very valid. [This popular answer on Stackoverflow](http://stackoverflow.com/a/235970/329063) exhibits exactly the problem you describe: it only works in the file you open first. I guess the solution will be an autocommand or something. – glts Feb 05 '13 at 21:32
  • @244an Currently using 7.0.237 – JamesB41 Feb 05 '13 at 21:52
  • ok, then you should go for using `match ...` as you already does. Look at the link that @glts wrote. You must do `match` with an autocmd for all mew tabs/windows. – 244an Feb 05 '13 at 21:58

1 Answers1

0

To highlight and strip trailing whitespace, you may be interested in my ShowTrailingWhitespace and DeleteTrailingWhitespace plugins, which implement this in a more robust way. (The pages contain links to alternative plugins, too.)

Ingo Karkat
  • 154,018
  • 15
  • 205
  • 275