+
+" BufExplorer.
+let g:bufExplorerShowRelativePath=1
+let g:bufExplorerSplitOutPathName=0
+
+" NERDcommenter.
+let g:NERDSpaceDelims=1
+endif "}}}1
+
+""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
+" Handle options only available in Vim 7.2 and above.
+""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
+if version >= "702" "{{{1
+if has("autocmd")
+ " http://vim.wikia.com/wiki/Highlight_unwanted_spaces
+ augroup WhitespaceMatch
+ autocmd!
+ au Display BufWinEnter * call Extra_Whitespace_Match()
+ au Display Syntax * call Extra_Whitespace_Match()
+ au Display BufWinLeave * call clearmatches()
+ augroup END
+
+ fun! Extra_Whitespace_Match() "{{{2
+ " \s\+ <whitespace>
+ " $ <before end of line>
+ " \@<! <unless preceded by>
+ " \%# <cursor position, ie when typing>
+ let l:pattern = '\s\+\%#\@<!$'
+ " Don't match single space in first column of diff.
+ if &ft =~# '^diff$\|git'
+ " \@! <unless also matching>
+ " \(^\s$\) <a single whitespace>
+ let l:pattern = '\(^\s$\)\@!' . l:pattern
+ endif
+
+ let l:hl = 'ctermfg=red guifg=red'
+ if ! &list
+ " Underline if we aren't using listchars.
+ let l:hl = l:hl . ' cterm=underline gui=underline'
+ endif
+ highlight clear ExtraWhitespace
+ exe "highlight ExtraWhitespace " . l:hl
+ if exists('w:whitespace_match_number')
+ try
+ call matchdelete(w:whitespace_match_number)
+ catch
+ endtry
+ call matchadd('ExtraWhitespace', l:pattern, 10, w:whitespace_match_number)
+ else
+ let w:whitespace_match_number = matchadd('ExtraWhitespace', l:pattern)
+ endif
+ endfun "}}}2
+
+ call Extra_Whitespace_Match()
+endif
+
+endif "}}}1
+
+""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
+" Handle options only available in Vim 7.3 and above.
+""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
+if version >= "703" "{{{1
+version 7.3
+
+" Toggle persistent undo with \u.
+call Mapping("u", ":call <SID>Cycle_Undo()<CR>:<CR>")
+" Remove persistent undo file with \U.
+call Mapping("U", ":call <SID>Clear_Undo()<CR>:<CR>")
+
+" Use a persistent undo file if it exists.
+fun! <SID>Check_Undo() "{{{2
+ if filereadable(undofile(expand("%")))
+ setlocal undofile
+ endif
+endfun "}}}2
+
+" Toggle persistent undo for this buffer.
+fun! <SID>Cycle_Undo() "{{{2
+ if has("persistent_undo")
+ let &undofile = ! &undofile
+ endif
+endfun "}}}2
+
+" Remove the persistent undo file for this buffer.
+fun! <SID>Clear_Undo() "{{{2
+ if ! has("persistent_undo")
+ return
+ endif
+
+ setlocal noundofile
+
+ let l:f = expand("%")
+ if l:f == ""
+ return
+ endif
+
+ let l:u = undofile(l:f)
+ if l:u == ""
+ return
+ endif
+
+ if ! filereadable(l:u) || ! filewritable(l:u)
+ return
+ endif
+
+ call delete(l:u)
+endfun "}}}2
+
+" Toggle ColorColumn at cursor position.
+fun! <SID>Cycle_ColorColumn() "{{{2
+ if ! has("syntax")
+ return
+ endif
+
+ let l:cc = &colorcolumn
+ let l:column = col(".")
+ let l:re = ",*\\<" . l:column . "\\>"
+ if l:cc =~# l:re
+ let l:cc = substitute(l:cc, l:re, "", "g")
+ else
+ let l:cc = l:cc . "," . l:column
+ endif
+ let &colorcolumn = substitute(l:cc, "^,*", "", "")
+endfun "}}}2
+
+if has("syntax")
+ " Enable showing ColorColumn at cursor position with \CC.
+ call Mapping("CC", ":call <SID>Cycle_ColorColumn()<CR>:<CR>")
+ " Remove last shown ColorColumn with \Cc.
+ call Mapping("Cc", ":let &colorcolumn=substitute(&colorcolumn, \",*[0-9]*$\", \"\", \"\")<CR>:<CR>")
+ " Remove all ColorColumns with \Cx.
+ call Mapping("Cx", ":se colorcolumn=<CR>:<CR>")
+endif
+
+" Use persistent undo if available.
+if has("autocmd")
+ if has("persistent_undo")
+ au File BufReadPost * call <SID>Check_Undo()
+ endif
+
+ if has("cursorbind")
+ au Display WinEnter * if &diff | se cursorbind | endif
+ endif
+endif