1

How can I change the syntax highlighting in vim for C/C++/PHP in particular? Can I also change the background color so it won't be the same as the shell's?

1
  • Btw in vim (not gvim) you are limited only to colors that your terminal supports! It's not many of them. Commented Aug 22, 2012 at 11:38

2 Answers 2

3

Before you start installing various plugins, check out pre-installed color schemes that ships with your Vim. In my case I have many of them:

# rpm -ql vim vim-common | grep color
/usr/share/vim/vim72/colors
/usr/share/vim/vim72/colors/README.txt
/usr/share/vim/vim72/colors/blue.vim
/usr/share/vim/vim72/colors/darkblue.vim
/usr/share/vim/vim72/colors/default.vim
/usr/share/vim/vim72/colors/delek.vim
/usr/share/vim/vim72/colors/desert.vim
/usr/share/vim/vim72/colors/elflord.vim
/usr/share/vim/vim72/colors/evening.vim
/usr/share/vim/vim72/colors/koehler.vim
/usr/share/vim/vim72/colors/morning.vim
/usr/share/vim/vim72/colors/murphy.vim
/usr/share/vim/vim72/colors/pablo.vim
/usr/share/vim/vim72/colors/peachpuff.vim
/usr/share/vim/vim72/colors/ron.vim
/usr/share/vim/vim72/colors/shine.vim
/usr/share/vim/vim72/colors/slate.vim
/usr/share/vim/vim72/colors/torte.vim
/usr/share/vim/vim72/colors/zellner.vim
/usr/share/vim/vim72/ftplugin/dircolors.vim
/usr/share/vim/vim72/syntax/colortest.vim
/usr/share/vim/vim72/syntax/dircolors.vim
/usr/share/vim/vim72/syntax/syncolor.vim
/usr/share/vim/vimfiles/after/colors
/usr/share/vim/vimfiles/colors

To change it just use this:

colorscheme darkblue

Also you can download color schemes and just drop them into your VIMRC subdirectory "colors" and load them the same way. I like this one for example: http://ethanschoonover.com/solarized

And of course, you can modify those color schemes. Just copy the "default.vim" (or the one you like) to your VIMRC/colors and edit it to change colors you want.

Sign up to request clarification or add additional context in comments.

2 Comments

I have these schemes also; I've managed to change the colorscheme but the syntax highlighting has not changed.
What you mean by "syntax highlighting has not changed"? All syntax definitions defines constants, not colors. All colors are defined in these files. So change it here if you want to tune it.
1

You have to give it a syntax file to load and play around with it:

http://www.vim.org/scripts/script.php?script_id=1571

To enable it (in case you don't know) its :set syntax

For info on changing vim's background check here:

Setting the VIM background colors

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.