+ exe l:resize
+endfun
+
+" Toggle number display.
+fun! Number(resize)
+ call Iain_Vars()
+ let &number = ! &number
+
+ if version >= "700"
+ let l:i = 0
+ let l:num_numbers = 0
+ while l:i <= winnr("$")
+ if getwinvar(l:i, "&number") == 1
+ let l:num_numbers = l:num_numbers + 1
+ endif
+ let l:i = l:i + 1
+ endwhile
+
+ if l:num_numbers == 0
+ let g:iainextracolumns = 0
+ if a:resize
+ call Resize_Columns("-")
+ endif
+ elseif g:iainextracolumns == 0
+ let g:iainextracolumns = 1
+ if a:resize
+ call Resize_Columns("+")
+ endif
+ endif
+ endif
+endfun
+
+" Restore window size.
+au Display VimLeave * if exists("g:oldcols") | call Resize_Columns("-", (&columns - g:oldcols)) | endif
+
+" Map Makefile mode.
+au Mode BufEnter * if &ft == "make" | call MakeMode_map() | endif
+au Mode BufLeave * if &ft == "make" | call MakeMode_unmap() | endif
+
+" Entering Make mode.
+fun! MakeMode_map()
+ call Iain_Vars()
+ let b:iainlist=1
+ call Cycle_List()
+ set ts=8
+ set noexpandtab
+endfun
+
+" Leaving Make mode.
+fun! MakeMode_unmap()
+ call Cycle_List()
+ set ts=2
+ set expandtab
+endfun
+
+" Show the status line for the first time.
+call Show_StatusLine()
+
+" Function to create mappings with either a hardcoded \ or <Leader>.
+fun! Mapping(keysequence,mapping)
+ if version < "600"
+ exec "map \\" . a:keysequence . " " . a:mapping
+ else
+ exec "map <Leader>" . a:keysequence . " " . a:mapping
+ endif
+endfun
+
+" Use - and = to create underlines.
+call Mapping("-", "yyp:s/./-/g<RETURN>:let @/=''<RETURN>:<RETURN>")
+call Mapping("=", "yyp:s/./=/g<RETURN>:let @/=''<RETURN>:<RETURN>")
+
+" Change to ts=2 with \2.
+call Mapping("2", ":se ts=2<CR>:<CR>")
+" Change to ts=4 with \4.
+call Mapping("4", ":se ts=4<CR>:<CR>")
+" Change to ts=8 with \8.
+call Mapping("8", ":se ts=8<CR>:<CR>")
+" Change to ts=16 with \6.
+call Mapping("6", ":se ts=16<CR>:<CR>")
+" Change to ts=32 with \3.
+call Mapping("3", ":se ts=32<CR>:<CR>")
+" Toggle paste mode with \p.
+call Mapping("p", ":se paste!<CR>:<CR>")
+" Swap case-sensitivity with \c.
+call Mapping("c", ":call Invert_Case()<CR>:<CR>")
+" Change number mode with \n.
+call Mapping("n", ":call Number(1)<CR>:<CR>")
+" Expand or shrink window size with \> and \<.
+call Mapping(">", ":call Resize_Columns('+')<CR>:<CR>")
+call Mapping("<", ":call Resize_Columns('-')<CR>:<CR>")
+" Clear search pattern with \/.
+call Mapping("/", ":let @/=\"\"<CR>:<CR>")
+
+" Forget the Ex mode mapping.
+map Q <NOP>
+
+" Vim tip 99: What's the highlighting group under the cursor?
+call Mapping("h", ":echo \"hi<\" . synIDattr(synID(line(\".\"),col(\".\"),1),\"name\") . '> trans<' . synIDattr(synID(line(\".\"),col(\".\"),0),\"name\") . \"> lo<\" . synIDattr(synIDtrans(synID(line(\".\"),col(\".\"),1)),\"name\") . \">\"<CR>")
+
+fun! Uncluttered_Buffer()
+ if exists("uncluttered_buffer")
+ if uncluttered_buffer == 1
+ return 1
+ endif
+ endif
+
+ if version >= "600"
+ if &buftype != ''
+ return 1
+ endif
+ endif
+
+ if &ft == 'perforce'
+ return 1
+ endif
+
+ if &ft == 'svn'
+ return 1
+ endif
+
+ if &ft == 'gitcommit'
+ return 1
+ endif
+
+ return 0
+endfun
+
+fun! Startup_Resize()
+ let l:columns = 0
+
+ " Resize for numbers.
+ if &number
+ if version >= "700"
+ let l:columns = &numberwidth
+ else
+ let l:columns = 8
+ endif
+ endif
+
+ " Resize for signs.
+ if has("signs")
+ if g:marksigns
+ if version >= "600"
+ let l:columns = l:columns + 2
+ endif
+ endif
+ endif
+
+ if g:oldcols < (80 + l:columns)
+ call Resize_Columns("+", l:columns)
+ endif
+endfun
+
+" Show numbers by default.
+au Display VimEnter * if ! Uncluttered_Buffer() | call Number(0) | endif
+endif
+
+""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
+" Handle options only available in Vim 6 and above.
+""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
+if version >= "600"
+version 6.0
+
+if has("win32")
+ se encoding=utf-8
+endif
+
+" Remember quickfix state.
+let g:quickfixing=0
+
+" Set indenting by filetype.
+filetype indent on
+
+" Less intrusive syntax highlighting.
+syn enable
+
+" Set colours.
+if has("gui_running")
+ try
+ if has("win32")
+ se guifont=DejaVu_Sans_Mono:h10:cANSI
+ else
+ se guifont=DejaVu\ Sans\ Mono\ 10
+ endif
+ catch
+ endtry
+endif
+if has("gui_running") || &t_Co > 16
+ try
+ colo iain
+ catch
+ endtry
+endif
+
+" Ignore whitespace when diffing.
+se diffopt=filler,iwhite
+
+" Expand window when doing a vertical diff.
+if &diff
+ if &columns < 161
+ let &columns = &columns * 2
+ endif
+endif
+
+" Remember that we are opening the quickfix window.
+au Mode BufWinEnter quickfix let g:quickfixing=1
+au Mode BufUnload * if &ft == "qf" | let g:quickfixing=0 | endif
+
+" Allow in-place editing of crontabs.
+au Mode FileType crontab set backupcopy=yes