Generally, I only use split panes inside of a Tab when using plugins like NerdTree, TagBar, and Codi, or when opening up helptags with :help. When I enter one of these panes, the Tab title text changes from the "primary" file name to __TagBar__.1, NERD_tree_1, or No Name, for the respective plugins, or something like map.txt.

How can I force Vim to freeze the original Tab title text, so that entering one of these panels will not change it? This default behavior becomes very annoying when you have multiple tabs open, and it becomes hard to tell which document is where.

FYI I have TabLine installed, but I believe this is also a problem without it.

  • You can use the 'tabline' setting to control the display of the tab title. In fact, that is all that plugin you linked to does! There is a "simplistic example that results in a tab pages line that resembles the default" in the docs, which you can modify to not change the tab label when the new buffer is of a certain buftype. Commented Jun 22, 2017 at 21:03
  • Can you copy/point me to that example? Can't seem to find it.
    – Luke Davis
    Commented Jun 22, 2017 at 23:16
  • Follow the setting-tabline tag in the "See setting-tabline for more info." ;-) Commented Jun 22, 2017 at 23:22

1 Answer 1


So I figured out a method by hijacking the content of the Tabline plugin. The function simply labels each tab by the first name in the list of open buffers with filetypes not in the list ["nerdtree","tagbar","codi","help"].

Just place the lines below anywhere in your .vimrc:

function! Tabline()
  let s = ''
  for i in range(tabpagenr('$'))
    let tab = i + 1
    let buflist = tabpagebuflist(tab)
    let bufignore = ['nerdtree', 'tagbar', 'codi', 'help']
    for b in buflist
      let buftype = getbufvar(b, "&filetype")
      if index(bufignore, buftype)==-1 "index returns -1 if the item is not contained in the list
        let bufnr = b
      elseif b==buflist[-1]
        let bufnr = b
    let bufname = bufname(bufnr)
    let bufmodified = getbufvar(bufnr, "&mod")
    let s .= '%' . tab . 'T'
    let s .= (tab == tabpagenr() ? '%#TabLineSel#' : '%#TabLine#')
    let s .= ' ' . tab .':'
    let s .= (bufname != '' ? '['. fnamemodify(bufname, ':t') . '] ' : '[No Name] ')
    if bufmodified
      let s .= '[+] '
  let s .= '%#TabLineFill#'
  return s
set tabline=%!Tabline()

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.