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 run the following vim command to change the colour of highlighted columns to something more palatable than the default red:

:highlight ColorColumn ctermbg=235 guibg=#2c2d27

rather than run this manually everytime I start vim, I'd like to automate this. But how? I've tried adding the following to .vimrc:

highlight ColorColumn ctermbg=235 guibg=#2c2d27

But that has no effect (no errors, it's just ignored after restart). Am I doing something wrong? I got the command from this Q:

http://stackoverflow.com/questions/2447109/showing-a-different-background-colour-in-vim-past-80-characters

But it didn't seem to shed light on my particular problem.

share|improve this question
1  
Add it to the colourscheme you are currently using... –  jasonwryan May 14 at 7:25

2 Answers 2

up vote 1 down vote accepted

You need to select a colorscheme prior to adding any highlight commands in your .vimrc file.

Example

colorscheme desert
highlight ColorColumn ctermbg=235 guibg=#2c2d27

References

share|improve this answer

It seems that your colorscheme had overrided your configuration. You can override it by the way in @slm's answer or create another configuration for colorscheme in ~/.vim/after/colors/<colorscheme name>.vim.

But you can always override settings in all colorscheme by adding this line to your .vimrc:

autocmd ColorScheme * highlight ColorColumn ctermbg=235 guibg=#2d2d27
share|improve this answer

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.