Makistos
10/28/2013 - 8:07 AM

This code adds a marker to any tablines if the file has been changed but not saved. #vim #viml

This code adds a marker to any tablines if the file has been changed but not saved. #vim #viml

" Add marker to tablines if file has been changed 
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 .= ' %*'
         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 .= (getbufvar(buflist[winnr - 1], "&mod")?'*':'').file
         let i = i + 1
      endwhile
      let s .= '%T%#TabLineFill#%='
      let s .= (tabpagenr('$') > 1 ? '%999XX' : 'X')
      return s
   endfunction
   set stal=2
   set tabline=%!MyTabLine()
endif