Vim: change label for specific tab

There's a nice little plugin called Taboo that makes this easy. Just install it and then you can change the tab title with:

:TabooRename My Tab Title

You can look at the source code for that plugin if you're interested in writing your own solution.


For gvim, see

:help 'guitablabel'
:help setting-guitablabel

Set the option to an expression that evaluates to t:mytablabel (a tab-local variable) if it exists, or else to an empty string (meaning to use the default):

:set guitablabel=%{exists('t:mytablabel')?t:mytablabel\ :''}

Maybe that is already too complicated, or maybe you want to get fancier. In that case, define a function:

function! GuiTabLabel()
  return exists('t:mytablabel') ? t:mytablabel : ''
endfunction
:set guitablabel=%{GuiTabLabel()}
:set go+=e

Then, in any tab where you want to override the default, do something like

:let t:mytablabel = 'homepage_template'

If you are using vim in a terminal, not gvim, then you have to set the 'tabline' option instead of 'guitablable'. This is a little more complicated, since you need a single expression that includes labels for all the open tabs. There is a complete example under

:help setting-tabline