Best way to insert timestamp in Vim?

前端 未结 10 1856
轮回少年
轮回少年 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:55

    I wanted a custom command :Date (not a key mapping) to insert the date at the current cursor position.

    Unfortunately straightforward commands like r!date result in a new line. So finally I came up with the following:

    command Date execute "normal i=strftime('%F %T')"
    

    which adds the date/time string at the cursor position without adding any new line (change to normal a add after the cursor position).

提交回复
热议问题