Add Syntax Highlighting to VIM on Mac OS X

It is extremely useful to be able to quickly edit code files inline in the mac terminal.  This post assumes you are at least somewhat familiar with the vim console text editor.  On mac by default you simply get plain text which whatever theme you are in.  For the homebrew theme you will see something like this for a simple ruby on rails controller file:

Screen Shot 2013-12-21 at 12.13.30 AM

It is much easier to look at and edit code if it is color coded.  It is quite simple to enable this on mac.  You just need to edit the .vimrc file to contain a few lines.  The .vimrc is usually located at the user root ~/.vimrc, if it does not exist you can create it using vim.

vim ~/.vimrc

Then add the following lines:

filetype plugin indent on

set term=builtin_ansi

syntax on

After adding these lines you should

Screen Shot 2013-12-21 at 12.12.22 AM

If you run into trouble, here is a link: http://vim.wikia.com/wiki/Turn_on_syntax_coloring_in_Mac_OS_X

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s