Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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

I just switched form Espresso to Vim for my programming work. I'm using the pre-installed version of Vim on my OS X 10.6. I changed the vimrc file in /usr/share/vim to:

" Configuration file for vim
set modelines=0     " CVE-2007-2438

" Normally we use vim-extensions. If you want true vi-compatibility
" remove change the following statements
set nocompatible    " Use Vim defaults instead of 100% vi compatibility
set backspace=2     " more powerful backspacing

set ai                  " auto indenting
set history=100         " keep 100 lines of history
set ruler               " show the cursor position
set number      " show line number
colorscheme desert
syntax on               " syntax highlighting
set hlsearch            " highlight the last searched term
filetype plugin on      " use the file type plugins

" Don't write backup file if vim is being called by "crontab -e"
au BufWrite /private/tmp/crontab.* set nowritebackup
" Don't write backup file if vim is being called by "chpass"
au BufWrite /private/etc/pw.* set nowritebackup

I also copied the desert.vim file to ~/.vim/colors, but vim still is only showing the default colorscheme.

I'd also like syntax heighlighting for PHP, HTML5, CSS3, JavaScript. Do I have to download this seperatly or are is this already installed in the default installation of Vim?

Is this the right stackexchange site for such questions? Or is the Apple Stackexchange site better for such questions?

share|improve this question
With the default colorscheme, does this command show colors that match their names? :runtime syntax/colortest.vim After executing :colorscheme desert, does the output of :scriptnames include desert.vim? What do the first lines of :version show? – garyjohn Jun 14 '11 at 15:53
@garyjohn After the running :runtime syntax/colortest.vim with the default color scheme, the command shows colors matching there names. After running :color scheme desert, and then :scriptnames, desert.vim is included in the list (among other color schemes I added). The first line of :version shows VIM - Vi IMproved 7.3 (2010 Aug 15, compiled Jun 24 2011 20:00:09). – wowpatrick Aug 6 '11 at 10:54
Since :runtime syntax/colortest.vim seemed to work, it looks like syntax highlighting basically works for you. If it didn't, I thought there might be a clue in the output of :version, specifically the first four lines which contain the version of Vim and a summary of the way it was built, e.g., as a Normal version. If you execute :colorscheme desert and the output of :scriptnames contains colors/desert.vim as the last file from any colors directory, then you should see the desert color scheme. I'm not sure what could be going wrong. What does :echo colors_name show? – garyjohn Aug 6 '11 at 22:22
@garyjohn: It seems like the color scheme has been work all the time along. The only thing that I don't understand (and also I thought it may not bee working) is the fact that the color scheme looks completely different in MacVim and in normal Vim in the console. Here you can see what I mean. At the bottom you can see the output of echo colors_name. Why do the two color schemes look different? – wowpatrick Aug 7 '11 at 22:55
Nice pictures! That helps. The color palette available to gvim or MacVim is different from that available to vim in a terminal. Even when terminals provide 256 colors, people often use just 16. If you open desert.vim, you'll see a block of color definitions for the GUI, including colors such as gold, tan and khaki, followed by a block of color definitions for a color terminal which uses just the normal and dark shades of the six basic ANSI colors and gray. So I think the two color schemes look different because the author chose to use a smaller set of colors for the terminal than for the GUI. – garyjohn Aug 8 '11 at 3:55
up vote 3 down vote accepted

Don't touch /usr/share/vim/vimrc. All your customizations, colorschemes, etc. are supposed to go into ~/.vim/ and ~/.vimrc.

Also (there are other ways but) you need to relaunch vim whenever you save your ~/.vimrc for it to apply your changes.

As is, Vim should be able to highlight PHP, HTML, CSS and JavaScript. You'll probably need alternative syntax files from if you want to work comfortably with CSS3 and HTML5.

For your colorscheme problem, try this:

  1. hit <Esc> to make sure you are in NORMAL mode
  2. type :colorscheme desert
  3. did it change anything?
share|improve this answer
Making changes to /usr/share/vim/vimrc and under /usr/share/vim/vimfiles is generally OK as long as you intend for the changes to apply to all users. It's making changes under $VIMRUNTIME, e.g., /usr/share/vim/vim73, that will bite you. You're right, though, that personal customizations should go into ~/.vimrc and ~/.vim. – garyjohn Jun 14 '11 at 15:38
:set colorscheme desert only returns E518: Unknown option: colorscheme. I also copied the third block of the /usr/share/vim/vimrc to ~/.vimrc. – wowpatrick Jun 14 '11 at 15:46
colorscheme is a command, not an option. I think romainl probably intended step 2 to be "type :colorscheme desert" to see if that command is working at all. – garyjohn Jun 14 '11 at 17:47
If I enter colorscheme desert, nothing happens. – wowpatrick Jun 14 '11 at 18:05
@garyjohn, exactly. I've edited my answer. – romainl Jun 14 '11 at 19:16

Your Answer


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.