MacOS – How to run VI with colors on Lion

colormacosterminalvi

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.

Best Answer

It’s a matter of having the right settings in your ~/.vimrc file. Here’s mine: https://github.com/mathiasbynens/dotfiles/blob/master/.vimrc.

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: