1

so i'm trying to configure vim (on windows 8.1) to take notes and i would like to configure F2 to add a date and time stamp and F3 to insert a line of '==================================='.

i've achieved success by using these lines in my _vimrc:

map <F2> :r! date /T<CR>:r! time /T<CR>
map <F3> :put='====================================='<CR>

the only problem is that they both insert a carriage return before inserting the text... i would like for both to start on the line that the cursor is on.

is there any way to do that?

i've looked in other stackoverflow topics suggesting using something like

map <F3> :execute "normal itextextext\<Esc>" 

and while that works if i type it in command mode, when i embed that in the _vimrc file, i get an error when i hit F3 telling me that there is a quote missing... i suspect that the escape character is somehow different or weird in windows but that's just a guess.

and for the :r! used for the date and time, i don't know anything that would mitigate the line skip.

any insight?

thanks.

jin

user3620332
  • 979
  • 6
  • 3
  • 1
    FYI, in my vimrc, i have this to insert timestamp: `ia dt =strftime("%Y-%m-%d %H:%M:%S")` – Kent May 09 '14 at 12:47

1 Answers1

0

For the first map you could use what is on a similar question: How do I insert current time into a file using vim.

About the second line, you do not need any ex command as put or execute:

map <F3> itextextext<Esc>
Community
  • 1
  • 1
mMontu
  • 8,983
  • 4
  • 38
  • 53