Vim Tip: Insert Time-Stamp

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

:r! date

About these ads

8 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 Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s