是的,当您开启了autochdir
时,默认选项卡标签会让选项卡变得非常烦人。基本上,如果您的:pwd
与文件位置不同,则它们会显示完整路径(缩写),如果您的:pwd
与文件位置相同,则仅显示文件名。当您开启autochdir
时,每次加载缓冲区(包括切换选项卡)时,您的:pwd
都会更改。我碰巧喜欢autochdir
,因为:ls
和任何文件操作都自动相对于活动缓冲区的cwd。我始终知道该位置,因为我的状态行中有完整路径。
我已将GUI选项卡设置为显示一些不同的内容...选项卡编号、修改指示器、如果选项卡中有多个窗口(显示计数),并始终仅显示缓冲区的文件名(如果有多个窗口,则使用活动窗口中的文件名)。
" GUI Tab label full path
function! GuiTabLabeler()
let tabno = tabpagenr()
let label = ''
let bufnrlist = tabpagebuflist(v:lnum)
" Add '+' if one of the buffers in the tab page is modified
for bufnr in bufnrlist
if getbufvar(bufnr, "&modified")
let label = '[+]'
break
endif
endfor
" Append the number of windows in the tab page if more than one
let wincount = tabpagewinnr(v:lnum, '$')
if wincount > 1
let label .= ' [' . wincount . ']'
endif
" Append the buffer name
return tabno . " " .
\ fnamemodify(bufname(bufnrlist[tabpagewinnr(v:lnum) - 1]), ":t")
\ . label
endfunction
set guitablabel=%!GuiTabLabeler()
标签页中的标签数字很好,特别是如果你将你的 Alt+数字键映射到它们上面时。
" Tab navigation in with alt-#
noremap <A-1> :tabnext 1<CR>
noremap <A-2> :tabnext 2<CR>
noremap <A-3> :tabnext 3<CR>
noremap <A-4> :tabnext 4<CR>
noremap <A-5> :tabnext 5<CR>
noremap <A-6> :tabnext 6<CR>
noremap <A-7> :tabnext 7<CR>
noremap <A-8> :tabnext 8<CR>
noremap <A-9> :tabnext 9<CR>
noremap <A-0> :tabnext 0<CR>
这样,我的GUI选项卡保持非常窄和干净。我更喜欢在状态栏中显示完整路径的文件名(以及其他内容):
" Statusline
set laststatus=2
let &statusline='%F %r%m [%{&fileformat}]%y[%{strlen(&fenc)?&fenc:&enc}]'
\ . '%= --%3p%% -- l:%3l, c:%3c (%03b 0x%02B)'