Turn on syntax highlighting for vi and vim in Mac OS X

Turning syntax highlighting for vi and vim in Mac OS X is as simple as creating a file called “.vimrc” in your home folder with the following content:

set nocompatible
syntax on


You may not like the standard color highlighting schema, but it can be easily changed. For example open some “.php” file and type :colorscheme followed by an space and the hit the tab key (or shift-tab to go backwards). You will see the different color schema names available in the system and then if you hit enter you’ll se immediately how it changes to the one you selected.

You can also set your default color highlighting schema in the “.vimrc” with “colo schemaname“:

set nocompatible
syntax on
colo default

The available schema names are those folder names inside the folder “/usr/share/vim/vimXX/” (the XX are 2 numbers that change for version to version of Mac OS X) without the “.vim” extension:

$ ls /usr/share/vim/`echo vim[0-9][0-9]`/colors/*.vim

My favorite one is “peachpuff”.

Ref: http://igoles.wordpress.com/2006/09/01/anadiendo-color-a-vim-en-mac-os-x/

You might also like

Nowdoc and heredoc in PHP
From the manual: Nowdocs are to single-quoted strings what heredocs are to double-quoted strings....
Fix “macports checking for Tcl configuration… configure: error: Can’t find Tcl configuration definitions” when selfupdating Macports in Mac OS X 10.9 Mavericks
I've just upgraded my Mac OS X to Mavericks 10.9. When I tried to update Macports I got an error and...
Add colors to the text in terminal application in Mac OS X
Just add the following 2 lines to your /etc/profile, ~/.profile or ~/.bash_profile: export CLICOLOR=1 export...
Password protect a Location, LocationMatch or VirtualHost in Apache (XAMPP and Mac OS X)
Protecting a Location or VirtualHost in Apache is very similar to protecting a folder as I explained...
Leave a comment ?


Leave a Comment