+" 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
+
+" Less intrusive syntax highlighting.
+syn enable
+
+" Nice GUI colour.
+if has("gui_running")
+ se guifont=Bitstream\ Vera\ Sans\ Mono\ 12
+ colo darkblue
+endif
+if has("win32")
+ se guifont=Bitstream_Vera_Sans_Mono:h10:cANSI
+endif
+
+" Expand window when doing a vertical diff.
+if &diff
+ let &columns = 164
+endif
+
+" Status bar matches the colour.
+highlight StatusLine guifg=white guibg=blue ctermbg=white ctermfg=blue
+
+" 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
+