Vim Tip: Insert Time-Stamp

To insert time-stamp in a file, you can exit from edit mode and type:

:r! date

11 thoughts on “Vim Tip: Insert Time-Stamp

  1. Brian Kalbfus says:

    Doesn’t work as easily in windows – you need to say:

    :r! date /T
    This only gets the date, though. the time you’d have to say:
    :r! time /T

    Before seeing this tip, I did this to use the Vim internal functions:
    :s/$/\=strftime(“%c”)^M:noh%M
    This puts the current date and time at the end of the current line. (remember that ^M is actually the enter key captured by preceding it with ctrl-q in windows or ctrl-v in other os)
    I put it in a macro so I can just hit @t to get the timestamp

Leave a comment