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

terminal

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
/usr/share/vim/vim73/colors/blue.vim
/usr/share/vim/vim73/colors/darkblue.vim
/usr/share/vim/vim73/colors/default.vim
/usr/share/vim/vim73/colors/delek.vim
/usr/share/vim/vim73/colors/desert.vim
/usr/share/vim/vim73/colors/elflord.vim
/usr/share/vim/vim73/colors/evening.vim
/usr/share/vim/vim73/colors/koehler.vim
/usr/share/vim/vim73/colors/morning.vim
/usr/share/vim/vim73/colors/murphy.vim
/usr/share/vim/vim73/colors/pablo.vim
/usr/share/vim/vim73/colors/peachpuff.vim
/usr/share/vim/vim73/colors/ron.vim
/usr/share/vim/vim73/colors/shine.vim
/usr/share/vim/vim73/colors/slate.vim
/usr/share/vim/vim73/colors/torte.vim
/usr/share/vim/vim73/colors/zellner.vim

My favorite one is “peachpuff”.

Ref: http://igoles.wordpress.com/2006/09/01/anadiendo-color-a-vim-en-mac-os-x/
http://alvinalexander.com/linux/vi-vim-editor-color-scheme-colorscheme

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....
“WARNING: soft rlimits too low” in MongoDB with Mac OS X
If you get this warning when you connect to mongo shell in Mac OX X: ** WARNING: soft rlimits too...
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...
Leave a comment ?

1 Comments.

    Leave a Comment

    Trackbacks and Pingbacks: