+ elseif Has_Unicode()
+ if w:iainlist == 1
+ " Just tabs.
+ return "»"
+ else
+ " Full list.
+ return "¶"
+ endif
+ else
+ if w:iainlist == 1
+ return "_"
+ else
+ return "\$"
+ endif
+ endif
+endfun "}}}2
+
+" Helper for status line.
+" Show c or C to denote case-sensitivity.
+fun! Show_Case() "{{{2
+ if &ic
+ return "c"
+ else
+ return "C"
+ endif
+endfun "}}}2
+
+" Helper for status line.
+" Show the size of the tabstop.
+fun! Show_Tabstop() "{{{2
+ return &ts
+endfun "}}}2
+
+" Helper for status line.
+" Show p when paste mode is on.
+fun! Show_Paste() "{{{2
+ if &paste
+ return "p"
+ else
+ return ""
+ endif
+endfun "}}}2
+
+" Helper for status line.
+" Show v when virtualedit mode is block, insert or onemore.
+" Show V when virtualedit mode is all.
+fun! Show_VirtualEdit() "{{{2
+ if ! has("virtualedit")
+ return ""
+ endif
+
+ if &ve == "all"
+ return "V"
+ elseif &ve
+ return "v"
+ else
+ return ""
+ endif
+endfun "}}}2
+
+" Helper for status line.
+" Show U when persistent undo is on.
+" Show u when persistent undo is off but an undofile exists.
+fun! Show_Undo() "{{{2
+ if ! exists("&undofile")
+ return ""
+ endif
+
+ if &undofile
+ return "U"
+ elseif filereadable(undofile(expand("%")))
+ return "u"
+ else
+ return ""
+ endif
+endfun "}}}2
+
+" Helper for status line.
+" Show alternate buffer number and name.
+fun! Show_Alt() "{{{2
+ let l:alt = bufnr("#")
+ if l:alt < 0 || l:alt == bufnr("") || ! b:iainalt
+ return ""
+ endif
+
+ return " " . l:alt . ": " . expand("#:t")
+endfun "}}}2
+
+" Helper for status line.
+" Show scrollbind or cursorbind.
+fun! Show_Bind() "{{{2
+ if has("cursorbind")
+ if &cursorbind
+ if Has_Unicode()
+ return "⇄"
+ else
+ return ">"
+ endif
+ elseif &scrollbind
+ if Has_Unicode()
+ return "⇅"
+ else
+ return "^"
+ endif
+ endif
+ endif
+ return ""
+endfun "}}}2
+
+" Show the status line.
+fun! Show_StatusLine() "{{{2
+ if ! has("statusline")
+ return
+ endif
+ call Iain_Vars()
+ let l:sl1='%2n\:\ %<%1*%f%0*\ [%{Show_List()}%{Show_Bind()}%{Show_Case()}%{Show_Tabstop()}%{Show_Paste()}%{Show_VirtualEdit()}%{Show_Undo()}%Y%M%R]%{Show_Alt()}\ '
+ let l:sl3='L:%1*%4.6l%0*/%-4.6L\ C:%1*%3.6c%0*\ \|\ %P'
+ let l:hexformat='%b'
+ if b:iainhex
+ let l:hexformat='0\x%02B'
+ endif
+ if b:iainverbose
+ let l:sl1=l:sl1 . v:version . '\ %='
+ let l:sl2=l:hexformat . '\ \|\ P:%4.6o\ '
+ else
+ let l:sl1=l:sl1 . '%='
+ let l:sl2=''
+ endif
+ exec "set statusline=" . l:sl1 . l:sl2 . l:sl3
+endfun "}}}2
+
+" Show the status line for the first time.
+call Show_StatusLine()
+endif "}}}1
+
+""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
+" Handle options only available in Vim 6 and above.
+""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
+if version >= "600" "{{{1
+version 6.0
+
+if has("gui_win32")
+ se encoding=utf-8
+endif
+
+" Remember quickfix state.
+if has("quickfix")
+ let g:quickfixing=0
+endif
+
+" Set indenting by filetype.
+filetype indent on
+
+" Less intrusive syntax highlighting.
+if has("syntax")
+ syn enable
+endif
+
+" Set colours.
+if has("gui_running")
+ if has("win32") || has("win64")
+ exe "silent se guifont=DejaVu_Sans_Mono:h10:cANSI"
+ else
+ exe "silent se guifont=DejaVu\\ Sans\\ Mono\\ 10"
+ endif
+endif
+if has("gui_running") || &t_Co > 16
+ exe "silent colo iain"
+endif
+
+" Ignore whitespace when diffing.
+if has("diff")
+ se diffopt=filler,iwhite
+endif
+
+if has("autocmd")
+ if has("quickfix")
+ " 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
+ endif
+
+ " Allow in-place editing of crontabs.
+ au Mode FileType crontab set backupcopy=yes
+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>
+
+" Set mark and update highlighting.
+if has("signs")
+ au Signs BufReadPost * call <SID>Highlight_Signs()
+ au Signs CursorHold * call <SID>Highlight_Signs()
+endif
+
+" Helper to set buffer variable for a given sign.
+fun! <SID>Prep_Sign(sign) "{{{2
+ if ! exists("b:sign" . a:sign) || ! g:marksigns
+ exe "let b:sign" . a:sign . "=0"
+ endif
+endfun "}}}2
+
+fun! <SID>Place_Sign(number, line, old, name) "{{{2
+ if a:line == a:old
+ return a:old
+ endif
+
+ exe "sign unplace " . (g:firstsign + a:number) . " buffer=" . bufnr("")
+ " Don't place the sign if it would conflict with the last change sign.
+ exe "sign place " . (g:firstsign + a:number) . " line=" . a:line . " name=" . a:name . " buffer=" . bufnr("")
+ return a:line
+endfun "}}}2
+
+fun! <SID>Highlight_Signs(...) "{{{2
+ if ! has("signs") || ! g:marksigns || Uncluttered_Buffer()
+ return
+ endif
+
+ let l:signs = g:iainsigns
+ let l:sign = ""
+ let l:i = 0
+ while strlen(l:signs)
+ let l:sign = matchstr(l:signs, '^[A-Za-z]\+\(:.\)*[.=-][^ ]\+')
+
+ let l:name = substitute(l:sign, '[:.=-].*', "", "")
+ let l:var = tolower(l:name)
+ let l:sign = substitute(l:sign, '^[A-Za-z]\+', "", "")
+ let l:ascii = matchstr(l:sign, '^:.')
+ let l:mark = substitute(l:sign, '^\(:.\)*[.=-]', "", "")
+ if strlen(l:ascii)
+ let l:ascii = substitute(l:ascii, '^:', "", "")
+ else
+ let l:ascii = l:mark
+ endif
+ let l:ascii = substitute(l:ascii, '"', '\\"', "")
+
+ call <SID>Prep_Sign(l:var)
+ exe "let " . l:var . " = <SID>Place_Sign(" . l:i . ", line(\"'" . l:ascii . "\"), b:sign" . l:var . ", \"Mark" . l:name . "\")"
+ let l:i = l:i + 1
+
+ let l:signs = substitute(l:signs, '^[^ ]\+ *', "", "")
+ endwhile
+endfun "}}}2
+
+" Toggle signs.
+fun! <SID>Cycle_Signs(resize) "{{{2
+ if ! has("signs")
+ return
+ endif
+ call Iain_Vars()
+ let g:marksigns = ! g:marksigns
+
+ " Retrofit arrays on to Vim 6.
+ if ! exists("g:iainsigns")
+ " Signs are defined in g:iainsigns. The syntax is as follows:
+ "
+ " Sign ::= Name (':' Mark)* Type Symbol
+ " Type ::= '=' | '-' | '.'
+ "
+ " Signs with Type '=' will be highlighted with the MarkSign group.
+ " Signs with Type '-' will be highlighted with the MarkLine group.
+ " Signs with Type '.' will be highlighted with the MarkDot group.
+ " Define the Mark where Symbol is not also the mark name, eg "']".
+ if Has_Unicode()
+ let g:iainsigns = "Dash:'=’ Dot:..• Quote:\"=” Caret:^.ʌ"
+ else
+ let g:iainsigns = "Dash=' Dot:..* Quote=\" Caret.^"
+ endif
+ let g:iainsigns = g:iainsigns . " Less=< Greater=> Left=( Right=) SquareLeft=[ SquareRight=] BraceLeft={ BraceRight=} a-a b-b c-c d-d e-e f-f A-A B-B C-C D-D E-E F-F"
+ endif
+
+ if g:marksigns
+ " Signs to highlight marks.
+ " Syntax won't work properly in Vim 6.
+ let l:signs = g:iainsigns
+ let l:sign = ""
+ while strlen(l:signs)
+ let l:sign = matchstr(l:signs, '^[A-Za-z]\+\(:.\)*[.=-][^ ]\+')
+
+ let l:sign = substitute(l:sign, ':.', "", "")
+ let l:sign = substitute(l:sign, '=', " texthl=MarkSign text=", "")
+ let l:sign = substitute(l:sign, '\.', " texthl=MarkDot text=", "")
+ let l:sign = substitute(l:sign, '-', " texthl=MarkLine linehl=MarkLine text=", "")
+
+ exe "sign define Mark" . l:sign
+
+ let l:signs = substitute(l:signs, '^[^ ]\+ *', "", "")
+ endwhile
+
+ if a:resize
+ call Resize_Columns("+", 2)
+ endif
+ call <SID>Highlight_Signs()
+ else
+ let l:i = 0
+ while l:i < 25
+ exe "sign unplace " . (g:firstsign + l:i)
+ let l:i = l:i + 1
+ endwhile
+
+ let l:signs = g:iainsigns
+ let l:sign = ""
+ while strlen(l:signs)
+ let l:sign = matchstr(l:signs, '^[A-Za-z]\+')
+
+ exe "sign undefine Mark" . l:sign
+ call <SID>Prep_Sign(tolower(l:sign))
+ let l:signs = substitute(l:signs, '^[^ ]\+ *', "", "")
+ endwhile
+
+ if a:resize
+ call Resize_Columns("-", 2)
+ endif
+ endif
+endfun "}}}2
+
+" Change list mode.
+fun! Cycle_List() "{{{2
+ " Pretty UTF-8 listchars.
+ if Has_Unicode()
+ let basic='tab:»·,trail:…,extends:«,precedes:»'
+ let eol='eol:¶'
+ if version >= "700"
+ let basic=basic . ',nbsp:•'
+ endif
+ else
+ let basic='tab:\\_,trail:_,extends:<,precedes:>'
+ let eol='eol:$'
+ if version >= "700"
+ let basic=basic . ',nbsp:+'
+ endif
+ endif
+ call Iain_Vars()
+ let w:iainlist = w:iainlist + 1
+ if w:iainlist > 2
+ let w:iainlist = 0
+ endif
+ if w:iainlist == 0
+ setlocal nolist
+ elseif w:iainlist == 1
+ exec "setlocal lcs=" . basic
+ setlocal list