pb2q, . , :
function UpdateModifiedTime(comment)
let savedPosition = getpos(".")
call cursor(1, 1)
let modified = a:comment . 'Modified:'
if search(modified, 'e') > 0
execute 'substitute/' . modified . '.*/' . modified . ' ' . strftime('%b %d, %Y %T') . '/'
endif
call setpos(".", savedPosition)
endfunction
(: , , Vim, golfing, , ).
Then you can define auto commands, for example:
autocmd BufWrite *.sh,*.ksh,*.bash call UpdateModifiedTime('## ')
autocmd BufWrite *.vim call UpdateModifiedTime('" ')
autocmd BufWrite *.py call UpdateModifiedTime('')
autocmd BufWrite *.c call UpdateModifiedTime('// ')
Note that I gave an empty comment character for Python. This is because I had lines '''in the file header for comments. You can use '# 'either '## 'or everything that tickles your imagination.
You can do something similar with Created.
source
share