0

I have the following [F3] key mapping defined in my .vimrc. This inserts a line of text into my file containing the current date such as 2012-01-20. It works in command or insert mode. How can I include an environment variable such as $LOGNAME or $HOME in this line so the output is something like 2012-01-20 - user123 -? Have tried variations of <C-R>=$LOGNAME<CR> however this only seems to work for the inoremap line.

nnoremap <F3> "=strftime("%Y-%m-%d")<CR>P
inoremap <F3> <C-R>=strftime("%Y-%m-%d")<CR>

migrated from serverfault.com Jan 20 '17 at 21:18

This question came from our site for system and network administrators.

2
nnoremap <F3> "=strftime("%Y-%m-%d").' - '.$LOGNAME<CR>P
inoremap <F3> <C-R>=strftime("%Y-%m-%d").' - '.$LOGNAME<CR>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.