tags:

views:

55

answers:

1

Someone in a previous question suggested the following for adding timestamps to VIM:

nmap <F3> a<C-R>=strftime("%Y-%m-%d %a %I:%M %p")<CR><Esc>
imap <F3> <C-R>=strftime("%Y-%m-%d %a %I:%M %p")<CR>

Instead of using F3, I'd like to insert the timestamp by executing a function instead. For example, typing :Now.

Unfortunately, I don't grok VIM scripting. Can someone help?

+4  A: 

:Now is not a function, it is a command. You can create command out of first mapping with the following code:

command -nargs=0 -bar Now execute "normal! a\<C-R>=strftime(\"%Y-%m-%d %a %I:%M %p\")\<CR>"
ZyX