+ return ""
+ 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.
+" Mark DOS buffers.
+fun! Show_DOS() "{{{2
+ if &ff == "unix"
+ return ""
+ endif
+ return &ff . ","
+endfun "}}}2
+
+" Helper for status line.
+" Show the size of the tabstop.
+fun! Show_Tabstop() "{{{2
+ if &et
+ return &ts
+ else
+ if Has_Unicode()
+ return &ts . "↹"
+ else
+ return &ts . "\\"
+ fi
+ endif
+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
+
+" Helper for status line.
+" Show marker if searchforward is unset.
+fun! Show_SearchForward() "{{{2
+ if version >= "702"
+ if ! v:searchforward
+ if Has_Unicode()
+ return "∆"
+ else
+ return "^"
+ endif
+ endif
+ endif
+ return ""
+endfun "}}}2
+
+" Helper for status line.
+" Show marks set in cursor line.
+fun! Show_Marks() "{{{2
+ if ! exists("g:iainsigns")
+ return ""
+ endif
+
+ let l:marks = ""
+
+ let l:signs = g:iainsigns
+ let l:sign = ""
+ let l:cursorline = line(".")
+ while strlen(l:signs)
+ let l:sign = matchstr(l:signs, '^[A-Za-z]\+\(:.\)*[.=>-][^ ]\+')
+ 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, '"', '\\"', "")
+
+ if l:ascii == "o"
+ let l:line = "."
+ else
+ let l:line = "'" . l:ascii
+ endif
+
+ " Ignore cursor line which will always match.
+ if l:line != "."
+ if l:cursorline == line(l:line)
+ let l:marks = l:marks . l:mark
+ endif
+ endif
+
+ let l:signs = substitute(l:signs, '^[^ ]\+ *', "", "")
+ endwhile
+
+ if l:marks == ""
+ return ""
+ else
+ return "M:" . l:marks . " "
+ endif
+endfun "}}}2
+
+" Helper for status lines.
+" Show Space plugin command.
+fun! Show_Space() "{{{2
+ if exists("*GetSpaceMovement")
+ let l:ret = GetSpaceMovement()
+ if l:ret != ""
+ if Has_Unicode()
+ let l:ret = "▭" . l:ret . Show_SearchForward()
+ else
+ let l:ret = "[" . l:ret . Show_SearchForward() . "]"
+ endif
+ endif
+ return l:ret
+ else
+ return Show_SearchForward()
+ endif
+endfun "}}}2
+
+" Show the status line.
+fun! Show_StatusLine() "{{{2
+ if ! has("statusline")
+ return
+ endif
+ call Iain_Vars()
+
+ " User{N} highlights %{N}*.
+ " Named highlight groups %#group% aren't available until Vim 7.
+ let l:normal = '%0*'
+ let l:bold = '%1*'
+
+ " sl1 contains left-aligned stuff.
+ " sl2 contains stuff shown only when verbose mode is enabled.
+ " sl3 contains right-aligned stuff.
+ let l:sl1='%2n\:\ %<' . l:bold . '%f' . l:normal . '\ [%{Show_Encoding()}%{Show_DOS()}%{Show_List()}%{Show_Bind()}%{Show_Case()}%{Show_Tabstop()}%{Show_Paste()}%{Show_VirtualEdit()}%{Show_Undo()}%Y%M%R%{Show_Space()}]%{Show_Alt()}\ '
+ let l:sl3='%{Show_Marks()}L:' . l:bold . '%4.6l' . l:normal . '/%-4.6L\ C:' . l:bold . '%3.6c%V' . l:normal . '\ \|\ %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("win32") || has("win64")
+ 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")
+ " The :syntax enable command tries to source the syntax.vim runtime script.
+ " Parsing this .vimrc will fail if for some reason the runtime doesn't
+ " exist, as could be the case if the binary was installed with no support
+ " files. GNU On Windows is one example of an incomplete installation.
+ try
+ syn enable
+ catch
+ endtry
+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, '"', '\\"', "")
+
+ if l:ascii == "o"
+ let l:line = "."
+ else
+ let l:line = "'" . l:ascii
+ endif
+
+ call <SID>Prep_Sign(l:var)
+ exe "let " . l:var . " = <SID>Place_Sign(" . l:i . ", line(\"" . l:line . "\"), 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.
+ " Signs with Type '>' will be highlighted with the MarkArrow group.
+ " Define the Mark where Symbol is not also the mark name, eg "']".
+ let 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"
+ if Has_Unicode()
+ let g:iainsigns = g:iainsigns . " Quote:\"=” Dash:'=’ Caret:^.ʌ Dot:..•"
+ if version < "704"
+ let g:iainsigns = g:iainsigns ." Cursor:o>▶"
+ endif
+ else
+ let g:iainsigns = g:iainsigns . " Quote=\" Dash=' Caret.^ Dot:..*"
+ if version < "704"
+ let g:iainsigns = g:iainsigns ." Cursor>o"
+ endif
+ endif
+ 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:name = substitute(l:sign, '[:.=>-].*', "", "")
+ 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, '^:', "", "")
+ let l:ascii = matchstr(l:ascii, '^.')
+ else
+ let l:ascii = l:mark
+ endif
+ let l:ascii = substitute(l:ascii, '"', '\\"', "")
+ let l:type = substitute(l:sign, '^:.', "", "")
+ let l:type = matchstr(l:type, '^.')
+
+ let l:hl = ""
+ if l:type == "="
+ let l:hl = "texthl=MarkSign text="
+ elseif l:type == "."
+ let l:hl = "texthl=MarkDot text="
+ elseif l:type == "-"
+ let l:hl = "texthl=MarkLine text="
+ elseif l:type == ">"
+ let l:hl = "texthl=MarkArrow text="
+ endif
+
+ exe "sign define Mark" . l:name . " " . l:hl . l:mark
+
+ 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