vim - What is a vimrc function to determine if a buffer has been modified? -


i have tabline function stole/modified somewhere, filename have asterisk before if has been modified since last time written disk (ie if :up perform action).

for example tabline when open vim -p file*.txt

file1.txt file2.txt file3.txt 

then after change file1.txt , don't save it:

*file1.txt file2.txt file3.txt 

my tabline function:

if exists("+showtabline")    function mytabline()       let s = ''       let t = tabpagenr()       let = 1       while <= 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 .= file          let = + 1       endwhile       let s .= '%t%#tablinefill#%='       let s .= (tabpagenr('$') > 1 ? '%999xx' : 'x')       return s    endfunction    set stal=2    set tabline=%!mytabline() endif 

i looking same , found %m , %m not suited, tells whether open buffer modified. cannot see if other buffers modified (especially tabs, important).

the solution function getbufvar. help:

let s .= (getbufvar(buflist[winnr - 1], "&mod")?'*':'').file 

instead of

let s .= file 

should trick. can used nicely show buffers open in 1 tab (in case of multiple splits).


Comments

Popular posts from this blog

c# - SharpSVN - How to get the previous revision? -

c++ - Is it possible to compile a VST on linux? -

url - Querystring manipulation of email Address in PHP -