Best way to insert timestamp in Vim?

前端 未结 10 1853
轮回少年
轮回少年 2020-11-30 18:25

EditPad Lite has a nice feature (CTRL-E, CTRL-I) which inserts a time stamp e.g. \"2008-09-11 10:34:53\" into your code.

10条回答
  •  生来不讨喜
    2020-11-30 18:50

    As an extension to @Swaroop C H's answer,

    ^R=strftime("%FT%T%z")
    

    is a more compact form that will also print the time zone (actually the difference from UTC, in an ISO-8601-compliant form).

    If you prefer to use an external tool for some reason,

    :r !date --rfc-3339=s
    

    will give you a full RFC-3339 compliant timestamp; use ns instead of s for Spock-like precision, and pipe through tr ' ' T to use a capital T instead of a space between date and time.

    Also you might find it useful to know that

    :source somefile.vim
    

    will read in commands from somefile.vim: this way you could set up a custom set of mappings, etc., and then load it when you're using vim on that account.

提交回复
热议问题