+
+" Highlight search results.
+se hlsearch
+
+" Syntax highlighting.
+syn on
+
+" Catch typos.
+command! W :w
+command! Wq :wq
+command! Wqa :wqa
+
+" Set up our variables.
+fun! Iain_Vars()
+ if ! exists("b:iainlist")
+ let b:iainlist = 0
+ endif
+ if ! exists("b:iainhex")
+ let b:iainhex = 0
+ endif
+ if ! exists("b:iainverbose")
+ let b:iainverbose = 0
+ endif
+endfun
+
+" Helper for status line.
+" Show space, underscore or dollar sign depending on list mode.
+fun! Show_List()
+ call Iain_Vars()
+ if b:iainlist == 0
+ " No list.
+ return " "
+ elseif b:iainlist == 1
+ " Just tabs.
+ return "_"
+ else
+ " Full list.
+ return "\$"
+ endif
+endfun
+
+" Helper for status line.
+" Show c or C to denote case-sensitivity.
+fun! Show_Case()
+ if &ic
+ return "c"
+ else
+ return "C"
+ endif
+endfun
+
+" Helper for status line.
+" Show the size of the tabstop.
+fun! Show_Tabstop()
+ return &ts
+endfun
+
+" Helper for status line.
+" Show p when paste mode is on.
+fun! Show_Paste()
+ if &paste
+ return "p"
+ else
+ return ""
+ endif
+endfun
+
+" Show the status line.
+fun! Show_StatusLine()
+ call Iain_Vars()
+ let sl1='%2n\:\ %<%f\ [%{Show_List()}%{Show_Case()}%{Show_Tabstop()}%{Show_Paste()}%Y%M%R]\ %='
+ let sl3='L:%4.6l/%-4.6L\ C:%3.6c\ \|\ %P'
+ let hexformat='%b'
+ if b:iainhex
+ let hexformat='0\x%02B'
+ endif
+ if b:iainverbose
+ let sl2=hexformat . '\ \|\ P:%4.6o\ '
+ else
+ let sl2=''
+ endif
+ exec "set statusline=" . sl1 . sl2 . sl3
+endfun
+
+" Restore window size.
+au VimLeave * if exists("oldcols") | let &columns=oldcols | endif
+
+" Map C mode.
+au BufEnter * if &ft == "c" || &ft == "cpp" | call CMode_map() | endif
+au BufLeave * if &ft == "c" || &ft == "cpp" | call CMode_unmap() | endif
+
+" Map Perl mode.
+au BufEnter * if &ft == "perl" | call PerlMode_map() | endif
+au BufLeave * if &ft == "perl" | call PerlMode_unmap() | endif
+
+" Map Makefile mode.
+au BufEnter * if &ft == "make" | call MakeMode_map() | endif
+au BufLeave * if &ft == "make" | call MakeMode_unmap() | endif
+
+" Entering C mode.
+fun! CMode_map()
+ let oldcinkeys=&cinkeys
+ let oldcinwords=&cinwords
+ set cinkeys=0{,0},:,0#,!^F,o,O,e
+ set cinwords=if,else,while,do,for,switch
+endfun
+
+" Leaving C mode.
+fun! CMode_unmap()
+ set cinkeys=oldcinkeys
+ set cinwords=oldcinwords
+endfun
+
+" Entering Perl mode.
+fun! PerlMode_map()
+ let oldcinkeys=&cinkeys
+ let oldcinwords=&cinwords
+ set cinkeys=0{,0},:,!^F,o,O,e
+ set cinwords=if,else,while,do,for,eval
+endfun
+
+" Leaving Perl mode.
+fun! PerlMode_unmap()
+ set cinkeys=oldcinkeys
+ set cinwords=oldcinwords
+endfun
+
+" Entering Make mode.
+fun! MakeMode_map()
+ set list
+ set noexpandtab
+endfun
+
+" Leaving Make mode.
+fun! MakeMode_unmap()
+ set nolist
+ set expandtab
+endfun
+
+" Show the status line for the first time.
+call Show_StatusLine()
+endif
+
+""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
+" Handle options only available in Vim 6 and above.
+""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
+if version >= "600"
+version 6.0
+
+" Track changing number mode.
+let g:numbercols=&columns
+let g:numberchanges=0
+
+" Less intrusive syntax highlighting.