Skip to content

Instantly share code, notes, and snippets.

@dahu
Created April 4, 2012 02:30
Show Gist options
  • Save dahu/2297202 to your computer and use it in GitHub Desktop.
Save dahu/2297202 to your computer and use it in GitHub Desktop.
Update Timestamp on BufWrite
" Update a timestamp on BufWrite
" Barry Arthur, 2012 04 04
function! UpdateTimestamp()
let old_pos = getpos('.')
let old_search = histget("search", -1)
g/^# \d\{4}-\d\d-\d\d \d\d:\d\d: \.0 +\d\{4} \/\s*sputnick/s/^.\{-}\/\s*sputnick\s*$/\="# " . strftime('%F %H:%M: .0 %z') . " \/ sputnick"/
exe "normal /".old_search
call setpos('.', old_pos)
endfunction
au BufWrite * call UpdateTimestamp()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment