How to change tab titles in vim to user-define names?

大憨熊 提交于 2020-01-13 07:14:30

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!