Yanking and pasting

So here I am wanting to paste a few lines I yank.
How I do it is v - go into visual mode, select the lines I want to yank, hit esc to go to normal mode , y to yank then I usually need to paste it on a new line.
But if I am in normal mode my cursor is at the end of some line.
So what I do is go to insert mode, hit enter to create a new line then hit esc again, normal mode then p to paste the chunk of text.
Then I go back up, v to go to visual mode, select the text I yanked and hit d to delete it.
I am sure this is too much of a struggle, so how do I do it the right way?
And while at it, when I want to yank from my text opened in vim, I do v, then select what I need then "+y to copy it to clipboard.
If I want to paste from clipboard I do :set paste to keep the formatting then p.
When I am done I do :set nopaste.
Nevermind, found my answer: so if I do yy instead of a simple y when yanking it does the trick.
It creates a new line in normal mode, I can just hit enter then p.

Ah yes, copy paste. I tend to do the visual method too, but you can do yank with y and do motion commands like with c or d. So things like yi to yank inside. y$ to yank to the end. And so on.

1 Like
A free service run by Zed A. Shaw for learncodethehardway.org.