From 2a3015e18dd1c2057f61d58011badd4e5a6add62 Mon Sep 17 00:00:00 2001 From: Iain Patterson Date: Tue, 19 May 2009 14:22:20 +0100 Subject: [PATCH] Tab bar. --- .vimrc | 78 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 77 insertions(+), 1 deletion(-) diff --git a/.vimrc b/.vimrc index b6ba9a8..ab318da 100644 --- a/.vimrc +++ b/.vimrc @@ -348,6 +348,8 @@ endif if has("win32") se guifont=DejaVu_Sans_Mono:h10:cANSI endif +hi! link TabLineSel StatusLine +hi! link TabLine StatusLineNC " Ignore whitespace when diffing. se diffopt=filler,iwhite @@ -484,6 +486,77 @@ endif if version >= "700" version 7.0 +" Tab line. +fun! Show_TabLine() + let s = "%#TabLineFill#Tabs:" + + for i in range(tabpagenr("$")) + let n = i + 1 + " Get the label. + let buflist = tabpagebuflist(n) + let winnr = tabpagewinnr(n) + let label = bufname(buflist[winnr - 1]) + if label == "" + let label = "No Name" + else + let label = fnamemodify(label, ":t") + if strlen(label) >= 18 + let label = label[0:17] . ".." + endif + endif + + " Find out if any buffer was modified. + let modified = '' + for j in buflist + if getbufvar(j, "&modified") == 1 + let modified = '+' + break + endif + endfor + + " Choose highlighting. + if n == tabpagenr() + let s .= "%#TabLineSel#[" . n . modified . " " . label . "]" + else + let s .= "%#TabLine# " . n . modified . " " . label . " " + endif + endfor + + " Padding. + let s .= "%#TabLine#%T" + return s +endfun + +" Per tab label for the GUI. +fun! Show_GUITabLine() + let s = "" + let buflist = tabpagebuflist(v:lnum) + let winnr = tabpagewinnr(v:lnum) + + let label = bufname(buflist[winnr - 1]) + if label == "" + let label = "[No Name]" + else + let label = fnamemodify(label, ":t") + if strlen(label) >= 18 + let label = label[0:17] . ".." + endif + endif + + for j in buflist + if getbufvar(j, "&modified") == 1 + let s .= "+" + break + endif + endfor + + let s .= " " . label + return s +endfun + +set tabline=%!Show_TabLine() +set guitablabel=%!Show_GUITabLine() + au CursorHoldI * call Highlight_StatusLine("H") au CursorMovedI * call Highlight_StatusLine("h") au FocusGained * call Highlight_StatusLine("F") @@ -498,13 +571,16 @@ se diffopt+=vertical se numberwidth=5 " Add "previous tab" mapping as gb. -map gb :tabPrev +map gb :tabprevious: " Transparency. if has("gui_macvim") se transparency=15 endif +" Yet more GUI options. Add tabs. +se go+=e + " Perforce. let g:p4EnableMenu=1 let g:p4Presets='P4CONFIG' -- 2.7.4