+ se guifont=DejaVu_Sans_Mono:h10:cANSI
+endif
+
+" Ignore whitespace when diffing.
+se diffopt=filler,iwhite
+
+" Expand window when doing a vertical diff.
+if &diff
+ let &columns = 164
+endif
+
+" Status bar matches the colour.
+highlight StatusLine guifg=white guibg=darkblue ctermbg=white ctermfg=darkblue
+
+" Numbers in blue.
+highlight LineNr term=underline cterm=bold guifg=blue ctermfg=blue
+
+" Remember that we are opening the quickfix window.
+au BufWinEnter quickfix let g:quickfixing=1
+au BufUnload * if &ft == "qf" | let g:quickfixing=0 | endif
+
+" Make * and # work the way you expect in visual mode.
+vnoremap * y/\V<C-R>=substitute(escape(@@,"/\\"),"\n","\\\\n","ge")<CR><CR>
+vnoremap # y?\V<C-R>=substitute(escape(@@,"?\\"),"\n","\\\\n","ge")<CR><CR>
+
+" Change list mode.
+fun! Cycle_List()
+ let basic='tab:\\_,trail:_,extends:<,precedes:>'
+ call Iain_Vars()
+ let b:iainlist = b:iainlist + 1
+ if b:iainlist > 2
+ let b:iainlist = 0
+ endif
+ if b:iainlist == 0
+ set nolist
+ elseif b:iainlist == 1
+ exec "set lcs=" . basic
+ set list
+ else
+ exec "set lcs=" . basic . ",eol:$"
+ set list
+ endif
+endfun
+
+" Cycle between hex and decimal display of toolbar stuff.
+fun! Cycle_HexStatusLine()
+ call Iain_Vars()
+ let b:iainhex = ! b:iainhex
+ call Show_StatusLine()
+endfun
+
+" Cycle verbose display of toolbar stuff.
+fun! Cycle_VerboseStatusLine()
+ call Iain_Vars()
+ let b:iainverbose = ! b:iainverbose
+ call Show_StatusLine()
+endfun
+
+" Toggle quickfix window.
+fun! Cycle_Quickfix()
+ if g:quickfixing == 1
+ cclose
+ let g:quickfixing=0
+ else
+ copen
+ endif
+endfun
+
+" We use Q for various commands. Unmap it.
+" Vim 5 won't let us unmap this as it treats Q as an ambiguous mapping (because
+" Qx also exists. With Vim 5 you are rewarded with Ex mode if you don't type
+" the Qx sequence quickly enough. Vim 6 allows us to forget the Ex mapping.
+map Q <Nop>
+
+" Swap hex/decimal statusline with Qx.
+map Qx :call Cycle_HexStatusLine()<CR>:<CR>
+" Change statusline verbosity with Qv.
+map Qv :call Cycle_VerboseStatusLine()<CR>:<CR>
+" Cycle list styles with Ql.
+map Ql :call Cycle_List()<CR>:<CR>
+" Toggle tags with Qt.
+map Qt :Tlist<CR>
+" Change foldmethod with Qf.
+map Qf :se foldenable!<CR>:<CR>
+" Toggle quickfix window with Qq.
+map Qq :call Cycle_Quickfix()<CR>:<CR>
+" Rerun filetype detection with Qs. The s is for syntax, as this will be
+" updated as a side-effect.
+map Qs :filetype detect<CR>:<CR>
+
+endif
+
+""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
+" Handle options only available in Vim 7 and above.
+""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
+if version >= "700"
+version 7.0
+
+" Change status bar colour when entering insert mode.
+fun! Highlight_StatusLine(flag)
+ " Get current status.
+ call Iain_Vars()
+
+ " Change the status based on the flag. XXX: Does Vim let us to do flags?
+ let re = "[" . tolower(a:flag) . toupper(a:flag) . "]"
+ let b:iainstatus = substitute(b:iainstatus, re, a:flag, "")
+
+ " Default colour.
+ let colour = "darkblue"
+ " Maybe override depending on status.
+ if b:iainstatus =~# "H"
+ if b:iainstatus =~# "I"
+ " Held in insert mode. Add extra highlight if we don't have focus.
+ if b:iainstatus =~# "f"
+ let colour = "darkmagenta"
+ else
+ let colour = "darkred"
+ endif
+ endif
+ else
+ if b:iainstatus =~# "I"
+ " Regular insert mode.
+ let colour = "darkred"
+ endif
+ endif
+
+ exec "highlight StatusLine guifg=white guibg=" . colour . " ctermbg=white ctermfg=" . colour
+endfun
+
+au CursorHoldI * call Highlight_StatusLine("H")
+au CursorMovedI * call Highlight_StatusLine("h")
+au FocusGained * call Highlight_StatusLine("F")
+au FocusLost * call Highlight_StatusLine("f")
+au InsertEnter * call Highlight_StatusLine("I")
+au InsertLeave * call Highlight_StatusLine("i")
+
+" Make diffs vertical by default.
+se diffopt+=vertical
+
+" Set size of numbers column.
+se numberwidth=5
+
+" Add "previous tab" mapping as gb.
+map gb :tabPrev<CR>