+
+" Look for ctags in home directory first.
+se tags=~/.tags,./tags,tags
+
+" Use - and = to create underlines.
+map - yyp:s/./-/g<RETURN>:let @/=''<RETURN>:<RETURN>
+map = yyp:s/./=/g<RETURN>:let @/=''<RETURN>:<RETURN>
+
+""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
+" Handle options only available in Vim 5 and above.
+""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
+if version >= "500"
+version 5.0
+
+" Vim 5 hardcodes the size of numbers column to 8.
+let numberwidth=8
+
+" Save sessions in UNIX format with / as file separator. This is
+" cross-platoform.
+se ssop+=unix,slash
+
+" Nuke any pre-existing autocommands.
+autocmd!
+
+" Save the current window width so we can restore it when we quit.
+let oldcols=&columns
+
+" More GUI options. Add icon, tearoffs and toolbar.
+se go+=itT
+
+" Allow dynamic window resize even if we aren't in an xterm.
+se t_WS=\e[8;%p1%d;%p2%dt
+
+" 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
+
+" Toggle case-sensitivity.
+fun! Invert_Case()
+ let &ic = ! &ic
+endfun
+
+" Restore window size.
+au VimLeave * if exists("oldcols") | let &columns=oldcols | endif
+
+" Map Makefile mode.
+au BufEnter * if &ft == "make" | call MakeMode_map() | endif
+au BufLeave * if &ft == "make" | call MakeMode_unmap() | endif
+
+" 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()
+
+" Change to ts=2 with Q2.
+map Q2 :se ts=2<CR>:<CR>
+" Change to ts=4 with Q4.
+map Q4 :se ts=4<CR>:<CR>
+" Change to ts=8 with Q8.
+map Q8 :se ts=8<CR>:<CR>
+" Change to ts=16 with Q6.
+map Q6 :se ts=16<CR>:<CR>
+" Change to ts=32 with Q3.
+map Q3 :se ts=32<CR>:<CR>
+" Toggle paste mode with Qp.
+map Qp :se paste!<CR>:<CR>
+" Swap case-sensitivity with Qc.
+map Qc :call Invert_Case()<CR>:<CR>
+" Change number mode with Qn.
+map Qn :se number!<CR>:<CR>
+" Expand or shrink window size with Q> and Q<. For use after toggling number.
+map Q> :exe 'se columns+=' . numberwidth<CR>:<CR>
+map Q< :exe 'se columns-=' . numberwidth<CR>:<CR>
+" Clear search pattern with Q/.
+map Q/ :let @/=""<CR>:<CR>
+
+endif
+
+""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
+" Handle options only available in Vim 6 and above.
+""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
+if version >= "600"
+version 6.0
+
+" Remember quickfix state.
+let g:quickfixing=0
+
+" Set indenting by filetype.
+filetype indent on
+
+" Less intrusive syntax highlighting.