Tuesday, February 19, 2013

Vim on OS X

Being Unix derived, it isn't a shock that OS X has the vim text editor pre installed. Nor is it surprising that this installation of vim is pre-built with a variety of features, including syntax highlighting for a variety of programming languages.

What is absolutely baffling, however, is that syntax highlighting appears to be disabled by default.  I say "appears" because I don't remember if it was once working on my system at any point.  What I do know is that earlier this afternoon, everything appeared monochrome in vim, yet the output of ls /usr/share/vim/vim73/syntax/ looks like this:
Look at all those colors. And that's not even all of them.
The solution is to either edit the system wide vim configuration file, or make a local copy of the file (and then edit it).  The file in question is /usr/share/vim/vimrc. If you want to make a local copy, copy it into your home directory, and rename it to .vimrc. Whichever choice you make, edit the file and add the following line:

syntax on

And that should do it!

No comments: