I find that the procedure to copy and paste in VIM is a bit tricky:
- Visual mode
- Y
- p (or shift p)
- insert mode
and if you wrongly hit the "delete" key, you lost the content (it is replaced by the char you deleted) and you have to re-copy it!
I’ve been working with Vim for several months, and I enjoy it, but the copy and paste mechanism annoys me.
Is there a way to simplify it? or some simpler alternative?
thank you
Vim maintains a list of the last 9 deletes you have made in the numbered registers. So
"0pwill paste the most recent thing you have yanked,"1pwill paste the 2nd most recent thing you have deleted or changed (note this does not include text that was simply yanked), and so on for registers 2-9.If you want to use more than the last 9 deleted items or if you want an easy way to access previous yanks I would recommend the yankring plugin which, among other things, lets you see your last 100 yanks and choose which one you want to paste with the
:YRShowcommand.Finally if you want to paste without leaving insert mode you can use
Ctrl-Rto insert the contents of any register. So in insert mode typing<Ctrl-R>"would insert the contents of the unnamed register"(which is where yanked text gets put when no register is specified).