vim显示标签页的序号
2014-01-12 21:47
260 查看
我们知道用ngt/ngT来切换标签,但当标签多时,还得一个个数,有点不方便。在vimrc中添加下面代码,就可以在标签上显示序号。
原文:http://blog.sina.com.cn/s/blog_6349518f0101i8gt.html
set tabline=%!MyTabLine() " custom tab pages line function MyTabLine() let s = '' " complete tabline goes here " loop through each tab page for t in range(tabpagenr('$')) " set highlight if t + 1 == tabpagenr() let s .= '%#TabLineSel#' else let s .= '%#TabLine#' endif " set the tab page number (for mouse clicks) let s .= '%' . (t + 1) . 'T' let s .= ' ' " set page number string let s .= t + 1 . ' ' " get buffer names and statuses let n = '' "temp string for buffer names while we loop and check buftype let m = 0 " &modified counter let bc = len(tabpagebuflist(t + 1)) "counter to avoid last ' ' " loop through each buffer in a tab for b in tabpagebuflist(t + 1) " buffer types: quickfix gets a [Q], help gets [H]{base fname} " others get 1dir/2dir/3dir/fname shortened to 1/2/3/fname if getbufvar( b, "&buftype" ) == 'help' let n .= '[H]' . fnamemodify( bufname(b), ':t:s/.txt$//' ) elseif getbufvar( b, "&buftype" ) == 'quickfix' let n .= '[Q]' else let n .= pathshorten(bufname(b)) endif " check and ++ tab's &modified count if getbufvar( b, "&modified" ) let m += 1 endif " no final ' ' added...formatting looks better done later if bc > 1 let n .= ' ' endif let bc -= 1 endfor " add modified label [n+] where n pages in tab are modified if m > 0 let s .= '[' . m . '+]' endif " select the highlighting for the buffer names " my default highlighting only underlines the active tab " buffer names. if t + 1 == tabpagenr() let s .= '%#TabLineSel#' else let s .= '%#TabLine#' endif " add buffer names if n == '' let s.= '[New]' else let s .= n endif " switch to no underlining and add final space to buffer list let s .= ' ' 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 .= '%=%#TabLineFill#999Xclose' endif return s endfunction
原文:http://blog.sina.com.cn/s/blog_6349518f0101i8gt.html
相关文章推荐
- Candy III
- PHP设置头部编码为UTF-8语句
- Linux crontab命令学习
- AD9516
- 软件工程-软件危机
- python itertools模块学习
- [转] C语言**位运算**终极剖析 分析的很详细
- python爬虫常用的模块
- 递归算法——归并排序,快速排序,二分查找
- C 语言中 setjmp 和 longjmp
- 2013最吃香的技能:Java称霸、Android势头正猛
- iOS- 用MapKit和CoreLocation 来实现移动设备(地图与定位)
- 据说,能把这个字符串题目做对的人,有,但寥寥无几!
- 中国名人排行榜2014年网络红人排行榜网络红人斌少
- 设计模式学习—建造者模式
- 获取WinCE已加载驱动的信息
- linux lcd设备驱动剖析三
- C# ArrayList类
- Centos 6.3 添加中文输入法
- 编译链接------nm 命令