I am trying to write a Vim command to append the date to the end of line. Right now I have the following, and it is not working.
nnoremap <F5> "=strftime("%c")<CR>A
What's wrong with this? It just throws me back into insert mode.
"=strftime("%c")<CR>A
means "put the date in the expression register then enter insert mode at the end of the line".
Here is what you wanted to do:
nnoremap <F5> A<C-r>=strftime("%c")<CR>
"enter insert mode at the end of the line and use the expression register to insert the date".
Here is another method, I'm sure there are others:
nnoremap <F5> :call setline(".", getline(".") . strftime("%c"))<CR>