+" 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()
+