我有一個tabline函數,我從某個地方偷走/修改過,但是我希望文件名前面有一個星號,如果它自上次寫入磁盤以來已被修改過(例如:up會執行一個動作)。什麼是vimrc函數來確定緩衝區是否被修改?
例如,這是我的tabline當我打開VIM -p文件* .TXT
file1.txt file2.txt file3.txt
後來我一改FILE1.TXT,不保存:
*file1.txt file2.txt file3.txt
我tabline功能:
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 .= 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
[Vim Buffer has been modified]可能重複(http://stackoverflow.com/questions/5606914/vim-buffer-has-been-modified) –