Closed jranke closed 7 years ago
I use the following code to update the Last Change line:
" Based on: http://vim.wikia.com/wiki/Insert_current_date_or_time
function! LastModified()
if &modified
let i = 1
let line = getline(1)
while i < 30 && line !~ "Last Change:"
let i += 1
let line = getline(i)
endwhile
if line =~ "Last Change:"
let curlang = v:lang
language C
let today = strftime("%a %b %d, %Y %I:%M%p")
exe "language " . curlang
let line = substitute(line, '\(.*\)Last Change:\(\s*\).*', '\1Last Change:\2' . today, "")
call setline(i, line)
endif
endif
endfun
autocmd BufWritePre *.vim call LastModified()
By the way, @jalvesaq, what plugin/script/snippet are you using for updating the Last Change: timestamp?