不幸的是,不能简单地使用tabpagenr()来查询当前标签页。显然,Vim 在评估时会在内部切换标签页'guitablabel'。作为一种解决方法,我使用 an:autocmd来设置选项卡范围的变量。这样,可以使用%{...}表达式为当前标签页添加星号:
au TabEnter * let t:current = 1
au TabLeave * let t:current = 0
set guitablabel=%{exists('t:current')&&t:current?'*':''}%N/\ %t\ %M