I would like to make a command that would insert at cursor todays date,
and also a command to insert some custom text.

In the help file it shows how to make a keybind to do this but I would
rather use a command - eg :date

I've had mappings in the past for things like

        inoremap <f4> <c-r>=strftime('%c')<cr>

which allows you to hit F4 in insert mode and have the date inserted. You can use a similar pattern if you need it at the command line:

        :put =strftime('%c')

(you can use "put!" to put it on the line above rather than the line below the current one)

This gives you more cross-platform support than just shelling out to the OS's "date" command, as the output (and even behavior & parameter format) of the OS's "date" command can vary widely.

-tim




Reply via email to