Enable syntax highlighting in Mac OSX Snow Leopard

One of the main reasons I switched to Mac was the fact that the user interface is polished and I still maintain the power and freedom I find Linux. But one downside in Mac Terminal is that there is no standard syntax highlighting.

So here is some info how I got to enable some basic syntax highlighting in Terminal and VIM. Note that these settings are user specific and not system wide.

Fire up Terminal and create a .vimrc file in your home directory.

vim .vimrc

Edit/create /usr/share/vim/vimrc for system wide settings.

Press the ‘i‘ key to switch vim to Insertion Mode, then enter these lines

set ai                  " auto indenting
set history=100         " keep 100 lines of history
set ruler               " show the cursor position
syntax on               " syntax highlighting
set hlsearch            " highlight the last searched term
filetype plugin on      " use the file type plugins

" When editing a file, always jump to the last cursor position
autocmd BufReadPost *
\ if ! exists("g:leave_my_cursor_position_alone") |
\ if line("'\"") > 0 &amp;&amp; line ("'\"") <= line("$") |
\ exe "normal g'\"" |
\ endif |
\ endif

Press the Escape key to take vim out of Insertion Mode, then press ‘:‘ (colon) followed by ‘x‘ to save the file and exit. Now when you list a directory or edit a file through vi(m) you’ll see that all syntaxes are highlighted.

Long live VI(M)!!