Skip to content

Instantly share code, notes, and snippets.

@caesar0301
Created July 22, 2022 16:55
Show Gist options
  • Save caesar0301/f510e0e1a21b93081ea06c9a223df05b to your computer and use it in GitHub Desktop.
Save caesar0301/f510e0e1a21b93081ea06c9a223df05b to your computer and use it in GitHub Desktop.
function! CustomizedTabLine()
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 .= ' '
let s .= i . ':'
let s .= '%*'
let s .= (i == t ? '%#TabLineSel#' : '%#TabLine#')
let file = bufname(buflist[winnr - 1])
let file = fnamemodify(file, ':p:t')
if file == ''
let file = '[No Name]'
endif
let s .= file
let s .= ' '
let i = i + 1
endwhile
let s .= '%T%#TabLineFill#%='
let s .= (tabpagenr('$') > 1 ? '%999XX' : 'X')
return s
endfunction
" Always show the tablilne
set stal=2
set tabline=%!CustomizedTabLine()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment