OS X VIM Syntax Highlighting
Posted Jun 12th, 2010 by Conor in in Linux,UNIXSyntax highlighting isn’t enabled by default on OS X, though it’s easy enough to set it up, and a few other small enhancments at the same it.
Start by executing this command:
cd /usr/share/vim && sudo vim vimrc
After entering your password press i to enter insertion mode and add the following lines after the line set backspace=2:
set showmatch " automatically show matching brackets
set binary noeol " do NOT put a carriage return at the end of the last line
set backspace=indent,eol,start " make that backspace key work the way it should
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 && line ("'\"") < = line("$") |
\ exe "normal g'\"" |
\ endif |
\ endif
The lines above add syntax highlighting and a few other useful things. The line set binary noeol is very important for web developers. For example if you are programming in PHP and you leave a space outside the closing ?> it will cause http headers to be needlessly sent. That line prevents that from happening.
Well that's it if you press ESC then type :wq you will return to the terminal. Try editing some files again and the highlighting should be enabled.