VIM allows has an option ‘tabline’ that one can use to configure how the tab line would look like. Back when I used to use gvim, I could very easily manipulate how the text on the tab looked like by setting the ‘guitablabel’ setting, however ‘tabline’ is not all that easy to configure.
Here is what I use now :
let s = ''
for i in range(tabpagenr('$'))
let tabnr = i + 1 " range() starts at 0
let winnr = tabpagewinnr(tabnr)
let buflist = tabpagebuflist(tabnr)
let bufnr = buflist[winnr - 1]
let bufname = fnamemodify(bufname(bufnr), ':t')
let s .= '%' . tabnr . 'T'
let s .= (tabnr == tabpagenr() ? '%#TabLineSel#' : '%#TabLine#')
let s .= ' ' . tabnr
let n = tabpagewinnr(tabnr,'$')
if n > 1 | let s .= ':' . n | endif
let s .= empty(bufname) ? ' [No Name] ' : ' ' . bufname . ' '
let bufmodified = getbufvar(bufnr, "&mod")
if bufmodified | let s .= '+ ' | endif
let s .= '%#TabLineFill#'
This is what it looks like :
The other day I wanted to open a scratch buffer to write some temporary code and the pass it on to a repl to test it out, the idea was that I could modify it as needed and resend it back to the repl and see the changes, helps to debug easily.
So I just wrote out this simple code here that allows me to launch a scratch buffer in different ways, but the difference is I can set various options for it while creating it. First lets have a look at the code :
function! functions#ScratchEdit(cmd, options)
exe a:cmd tempname()
setl buftype=nofile bufhidden=wipe nobuflisted
if !empty(a:options) | exe 'setl' a:options | endif
command! -bar -nargs=* Sedit call functions#ScratchEdit('edit', <q-args>)
command! -bar -nargs=* Ssplit call functions#ScratchEdit('split', <q-args>)
command! -bar -nargs=* Svsplit call functions#ScratchEdit('vsplit', <q-args>)
command! -bar -nargs=* Stabedit call functions#ScratchEdit('tabe', <q-args>)