0
点赞
收藏
分享

微信扫一扫

VIM 自定义TabLine禁签


环境:macOS1015.3 

vim 的标签页的切换可以用[n]gt命令来实现,n是第几个标签,但有时需要数一下才知是第几个,有点麻烦,看了一下vim的帮助,可以自定义标签,加个序号进去。 并改了一下样式(在颜色方案里改TabLine TabLineFill TabLineSel颜色),加点装饰,先看效果:

VIM 自定义TabLine禁签_python脚本

修改方式:

在.vimrc里添加下面 vimscript

" 自定定义tabpage的label (参考:help tabpage)
set tabline=%!MyTabLine()
function MyTabLine()
let s = ''
for i in range(tabpagenr('$'))
" select the highlighting
if i + 1 == tabpagenr()
let s .= '%#TabLineSel#'
else
let s .= '%#TabLine#'
endif

" set the tab page number (for mouse clicks)
let s .= '%' . (i + 1) . 'T'

" the label is made by MyTabLabel()
let s .= '%{MyTabLabel(' . (i + 1) . ')}'
endfor

" after the last tab fill with TabLineFill and reset tab page nr
let s .= '%#TabLineFill#%T'

" right-align the label to close the current tab page
if tabpagenr('$') > 1
let s .= '%=%#TabLine#%999XX'
endif

return s
endfunction
function MyTabLabel(n)
let buflist = tabpagebuflist(a:n)
let winnr = tabpagewinnr(a:n)

" Add '+' if one of the buffers in the tab page is modified
let label = ''
for bufnr in buflist
if getbufvar(bufnr, "&modified")
let label = '+'
break
endif
endfor

"添加tabpage序号,方便ngt切换
let bg=['☰','☱','☲','☳','☴','☵','☶','☷'][(a:n-1)%8]
return ' 🐶['.a:n.label.']'.pathshorten(bufname(buflist[winnr - 1])).' '
endfunction

 

 

参考:​​原创 在线vim配色加term与gui统一颜色调整python脚本​​

举报

相关推荐

0 条评论