Best way to insert timestamp in Vim?

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

    To make it work cross-platform, just put the following in your vimrc:

    nmap  i=strftime("%Y-%m-%d %a %I:%M %p")
    imap  =strftime("%Y-%m-%d %a %I:%M %p")
    

    Now you can just press F3 any time inside Vi/Vim and you'll get a timestamp like 2016-01-25 Mo 12:44 inserted at the cursor.

    For a complete description of the available parameters check the documentation of the C function strftime().

提交回复
热议问题