Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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?

share|improve this question
Have you tried moving this to .gvimrc ? I believe that will be processed after .vimrc. – Jack M. Nov 15 '10 at 17:34
@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 Nov 16 '10 at 18:32
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 Nov 14 '11 at 12:26
up vote 3 down vote accepted

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.

share|improve this answer

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.

share|improve this answer

You must log in to answer this question.

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