Macvim color scheme conflicting with .vimrc

3

In my .vimrc, I specify that when I do a search, I want the terms to be highlighted - background color yellow, foreground black. Here's how I specify that:

" Settings for terminal version of vim
:highlight Search ctermbg=yellow ctermfg=black
" Settings for gvim (linux) / macvim
:highlight Search guibg=yellow guifg=black

I'm also using a nice color scheme (railscasts) in Macvim. It seems to override my highlighting colors, however, to something barely visible. If I reload my .vimrc, all is well again.

Is there a way to cause my .vimrc settings to win in any conflicts with the color scheme? If not, would it be better to modify the color scheme itself? Write a little script that causes vim to automatically reload the .vimrc after the color scheme loads? What's the best approach here?

Nathan Long

Posted 2010-11-15T16:53:53.733

Reputation: 20 371

1Have you tried moving this to .gvimrc ? I believe that will be processed after .vimrc. – Jack M. – 2010-11-15T17:34:38.987

@Jack M. - that indeed was the problem. If you care to make your comment into an answer, I will accept it. :) Thank you! – Nathan Long – 2010-11-16T18:32:51.180

Update - I am now using the Solarized color scheme, which is very easy to read and, among other things, sets a good highlighting color for me, so I don't have to do the above at all. – Nathan Long – 2011-11-14T12:26:48.913

Answers

4

You probably want to move these colours into .gvimrc instead of .vimrc. .gvimrc is processed later as it is intended to override settings and be specific for GVim.

Jack M.

Posted 2010-11-15T16:53:53.733

Reputation: 3 133

0

Order is important. Are you running these :highlight commands before or after your :colorscheme command? If it's before, try changing the order.

However, there are reasons this still may not work. If this is the case, you can try putting your :highlight commands in ~/.vim/after/syntax/syncolor.vim (I'm not sure what the MacOS equivalent of this path would be), which is automatically loaded on various events.

Heptite

Posted 2010-11-15T16:53:53.733

Reputation: 16 267