How do I insert the current date/time stamp into the file?

You can use the strftime() function to insert the current data/time stamp in a file. For example, you can use the following abbreviation:

    iabbrev dts =strftime("%y/%m/%d %H:%M")

With this abbreviation, when you type dts in insert mode, it will be expanded to the date/time stamp. Some other forms of the above abbreviation are listed below:

    iabbrev mdyl =strftime("%a %d %b %Y")

    iabbrev mdys =strftime("%y%m%d")

    iabbrev mdyc =strftime("%c")

    iabbrev hml  =strftime("%d/%m/%y %H:%M:%S")

    iabbrev hms  =strftime("%H:%M:%S")

Comments (1)


Pepsh Pepshinsky

Let’s see you to :help viminfo-file-name (option -i) :set viminfofile=NONE


Speak Your Mind