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

Add Twig syntax highlight in Sublime Text 2
Select the "Preferences->Browse Packages..." menu to open the folder that contains Sublime Text 2 packages. Download...

Force a file system check (fsck) on next system boot for CentOS
It's as simple as creating an empty file in the root called forcefsck:touch /forcefsck...

Nowdoc and heredoc in PHP
From the manual:Nowdocs are to single-quoted strings what heredocs are to double-quoted strings....

Nowdoc and heredoc in PHP
From the manual:Nowdocs are to single-quoted strings what heredocs are to double-quoted strings....

  1. Great, tis a lot!

  2. It works! thanks

  3. FWIW you don’t need a regex to do the directory listing you are looking for. This works too:
    ls /usr/share/vim/vim*/colors/*.vim

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.