Ask Different is a question and answer site for power users of Apple hardware and software. 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

I'm looking to enable color syntax highlighting in vi. I just enabled colors in Terminal via here. Any ideas on how to enable this?

NOTE: Usually on Linux when I open vi with vi file.txt and it opens in black and white on default, I can open the same file with vim file.txt and it will show the colors, but this does not work here.

share|improve this question
up vote 14 down vote accepted

It’s a matter of having the right settings in your ~/.vimrc file. Here’s mine:

The key is to add this:

" Enable syntax highlighting
syntax on

You can install color schemes in your ~/.vim/colors directory. To enable a colorscheme, use:

" Select a colorscheme
colorscheme molokai

I’m using Molokai, which looks like this when editing a JavaScript file:

share|improve this answer
Thanks, this is exactly what I was looking for! EDIT: On a side note, adding colorsheme molokai yielded E185: Cannot find color scheme molokai. But the syntax part still worked! :) – gusterlover6 Mar 29 '12 at 16:36
@gusterlover6 Yeah, as I explained in my post you need to have the Molokai colorscheme installed in ~/.vim/colors/molokai.vim. You can download it from the link in my answer. Enjoy! – Mathias Bynens Mar 29 '12 at 16:43
If you use Janus you get easy access to colour schemes (and plugins). – Ian C. Mar 29 '12 at 16:52

I'll also say that MacVim is a nice upgrade from the standard Vim that ships with OS X, but it isn't necessary. What you need is Vim configuration that adds syntax highlighting to VIM.

The fastest way to get that is with Janus -- it's a set of VIM plugins and configuration files pre-configured and ready to go. It works with Vim and MacVim.

To install it:

curl -Lo- | bash

And then follow the instructions. That calls their automatic installer. It requires Vim 7.3 or greater. You'll get an easy path to colours and plugins in Vim.

Vim with Janus

share|improve this answer

You need to customize your ~/.vimrc to enable syntax highlighting, among other things. Very simplistically, you'll want to add:

syntax on

Google "vimrc" for sample vim configuration files.

share|improve this answer
It drives me mad when people say to "google stuff" in a stackexchange answer - how do you think folks got to the question in the first place?! – ZincX Jun 11 '13 at 9:15

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.