在Vim中,使用tabline选项配置在屏幕顶部(使用选项卡)时形成标签页行的文本.
@H_502_1@我想对默认标签页行进行一些微小的调整,例如用标签的索引替换标签中的窗口数.不幸的是,默认版本(当tabline未设置时处于活动状态)是复杂且无文档的.没有什么可以调整的.
@H_502_1@是否有一块Vim脚本提供了我可以根据需要调整的默认实现?
我使用一个自定义函数从
here复位标签号和视口号(见Tonymec的评论).您可以使用它来更改显示选项卡的方式.
@H_502_1@这是我的.vimrc中的.这只是一个稍微修改的版本,它改变了选项卡#和视口#的显示方式.
原文链接:https://www.f2er.com/bash/383926.html"Rename tabs to show tab# and # of viewports if exists("+showtabline") function! MyTabLine() let s = '' let wn = '' let t = tabpagenr() let i = 1 while i <= tabpagenr('$') let buflist = tabpagebuflist(i) let winnr = tabpagewinnr(i) let s .= '%' . i . 'T' let s .= (i == t ? '%1*' : '%2*') let s .= ' ' let wn = tabpagewinnr(i,'$') let s .= (i== t ? '%#TabNumSel#' : '%#TabNum#') let s .= i if tabpagewinnr(i,'$') > 1 let s .= '.' let s .= (i== t ? '%#TabWinNumSel#' : '%#TabWinNum#') let s .= (tabpagewinnr(i,'$') > 1 ? wn : '') end let s .= ' %*' let s .= (i == t ? '%#TabLineSel#' : '%#TabLine#') let bufnr = buflist[winnr - 1] let file = bufname(bufnr) let buftype = getbufvar(bufnr,'buftype') if buftype == 'nofile' if file =~ '\/.' let file = substitute(file,'.*\/\ze.','','') endif else let file = fnamemodify(file,':p:t') endif if file == '' let file = '[No Name]' endif let s .= file let s .= (i == t ? '%m' : '') let i = i + 1 endwhile let s .= '%T%#TabLineFill#%=' return s endfunction set stal=2 set tabline=%!MyTabLine() endif@H_502_1@这里是我的功能中定义的颜色
set tabpagemax=15 hi TabLineSel term=bold cterm=bold ctermfg=16 ctermbg=229 hi TabWinNumSel term=bold cterm=bold ctermfg=90 ctermbg=229 hi TabNumSel term=bold cterm=bold ctermfg=16 ctermbg=229 hi TabLine term=underline ctermfg=16 ctermbg=145 hi TabWinNum term=bold cterm=bold ctermfg=90 ctermbg=145 hi TabNum term=bold cterm=bold ctermfg=16 ctermbg=145