Vim Tips Wiki
Advertisement

Rather than shell out and run `date +%s000`, then copy and paste that new timestamp into a :%s/oldstamp/newstamp/ replacement, this script does it with three keystrokes and no mouse

" add this to your ~/.vimrc file, then type '\ts' to update timestamp to current
fun! ReplaceTimestamp()
   let tstamp = strftime("%s000")
   exe ":%s#<property name='p2.timestamp' value='[0-9]\\+'/>#<property name='p2.timestamp' value='" . tstamp . "'/>#g"
   echo "New time: " . tstamp
endfun
nnoremap <Leader>ts :call ReplaceTimestamp()<CR>
Advertisement