问题
I am using gvim for linux.
I got a few tab pages open and a couple of windows open per tab page.
I want to change the name of the tab pages to something significant to each project, as they are loaded separately in each tab.
Normally tab pages are name after filenames, but I want to change them to specific project names.
I tried to use set guitablabel, but it changes all the tabs not only the current one.
回答1:
You can try something like this:
fun! MyTabLabel()
let s:title = gettabvar(tabpagenr(), 'TabLabel')
if s:title == ""
return pathshorten(@%)
endif
return s:title
endf
:set guitablabel=%!MyTabLabel()
Then you just have to set the t:TabLabel variable in a tab to change its title. (It will change it just after you switch to another tab)
回答2:
yes, you have to set the tabline option. Also you may want to check :h setting-tabline for how to write your own tablabel function, there is an example.
来源:https://stackoverflow.com/questions/25322079/how-to-change-tab-titles-in-vim-to-user-define-names