add tab numbering to vim (and fix merge conflict)
authorAndrew Lorimer <andrew@lorimer.id.au>
Fri, 7 Jun 2019 05:33:05 +0000 (15:33 +1000)
committerAndrew Lorimer <andrew@charles.cortex>
Fri, 7 Jun 2019 05:35:38 +0000 (15:35 +1000)
vim/.vimrc
index 1df31674a537614ebcf6a4d76bf9751cd89f3a72..dbb2096bdefb55f69e2c8317f403aa270efe0f07 100644 (file)
@@ -7,3 +7,45 @@ set nu
 set expandtab
 set shiftwidth=2
 set softtabstop=2
+
+if has('gui')
+  set guioptions-=e
+endif
+if exists("+showtabline")
+  function MyTabLine()
+    let s = ''
+    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 .= ' ' . i
+      if tabpagewinnr(i,'$') > 1
+        let s .= ':' . winnr . '/' . tabpagewinnr(i,'$')
+      endif
+      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 i = i + 1
+    endwhile
+    let s .= '%T%#TabLineFill#%='
+    let s .= (tabpagenr('$') > 1 ? '%999XX' : 'X')
+    return s
+  endfunction
+  set tabline=%!MyTabLine()
+endif