I'm trying to create a vim keymapping that will initiate the creation of a new file, with the name of the file prefixed with the current date, waiting for me to finish typing the filename.
Put more precisely, I want to hit <Leader>n
, and have vim enter for me in the command line:
:new 2014-08-05-
... waiting for me to complete the filename and hit <CR>
.
How can I do this? I've tried this, but it didn't do quite what I expected, as it just echo-ed the date. How can I get vim to dynamically insert characters into the command line? Am I missing something simple?
function! NewNotesFile()
echon ":new " . strftime("%F")
endfunction
nnoremap <Leader>n :call NewNotesFile()<CR>