Skip to content
Browse files

Add tabline setting

  • Loading branch information...
1 parent 1ee4906 commit 7d597699ce983a8cc366a5e2d7d8b5b2b3735166 @hanzhixing committed
Showing with 70 additions and 0 deletions.
  1. +35 −0 vimrc.with_plugins
  2. +35 −0 vimrc.without_plugins
View
35 vimrc.with_plugins
@@ -62,6 +62,41 @@ set statusline=%F%m%r%h%w%y
\(exists(\"+bomb\")\ &&\ &bomb)?\",BOM\":\"\").\"]\"}
\\ [%{&ff}]\ [%l,%v(%p%%)]\ [LEN=%L]\ [\\%03.3b,\0x%04.4B]
+" Set tabline
+set showtabline=2 " always show tabs in gvim, but not vim
+" set up tab labels with tab number, buffer name, number of windows
+function! GuiTabLabel()
+ let label = ''
+ let bufnrlist = tabpagebuflist(v:lnum)
+ " Add '+' if one of the buffers in the tab page is modified
+ for bufnr in bufnrlist
+ if getbufvar(bufnr, "&modified")
+ let label = '+'
+ break
+ endif
+ endfor
+ " Append the tab number
+ let label .= v:lnum.': '
+ " Append the buffer name
+ let name = bufname(bufnrlist[tabpagewinnr(v:lnum) - 1])
+ if name == ''
+ " give a name to no-name documents
+ if &buftype=='quickfix'
+ let name = '[Quickfix List]'
+ else
+ let name = '[No Name]'
+ endif
+ else
+ " get only the file name
+ let name = fnamemodify(name,":t")
+ endif
+ let label .= name
+ " Append the number of windows in the tab page
+ let wincount = tabpagewinnr(v:lnum, '$')
+ return label . ' [' . wincount . ']'
+endfunction
+set guitablabel=%{GuiTabLabel()}
+
" Enable syntax highlight.
syntax on
View
35 vimrc.without_plugins
@@ -56,6 +56,41 @@ set statusline=%F%m%r%h%w%y
\(exists(\"+bomb\")\ &&\ &bomb)?\",BOM\":\"\").\"]\"}
\\ [%{&ff}]\ [%l,%v(%p%%)]\ [LEN=%L]\ [\\%03.3b,\0x%04.4B]
+" Set tabline
+set showtabline=2 " always show tabs in gvim, but not vim
+" set up tab labels with tab number, buffer name, number of windows
+function! GuiTabLabel()
+ let label = ''
+ let bufnrlist = tabpagebuflist(v:lnum)
+ " Add '+' if one of the buffers in the tab page is modified
+ for bufnr in bufnrlist
+ if getbufvar(bufnr, "&modified")
+ let label = '+'
+ break
+ endif
+ endfor
+ " Append the tab number
+ let label .= v:lnum.': '
+ " Append the buffer name
+ let name = bufname(bufnrlist[tabpagewinnr(v:lnum) - 1])
+ if name == ''
+ " give a name to no-name documents
+ if &buftype=='quickfix'
+ let name = '[Quickfix List]'
+ else
+ let name = '[No Name]'
+ endif
+ else
+ " get only the file name
+ let name = fnamemodify(name,":t")
+ endif
+ let label .= name
+ " Append the number of windows in the tab page
+ let wincount = tabpagewinnr(v:lnum, '$')
+ return label . ' [' . wincount . ']'
+endfunction
+set guitablabel=%{GuiTabLabel()}
+
" Enable syntax highlight.
syntax on

0 comments on commit 7d59769

Please sign in to comment.
Something went wrong with that request. Please try again.