Vim Scoops / Lessons / Copy and paste
How to copy and paste in Vim
Press yy to copy the current line, then p to paste it below the cursor or P to paste above. To cut instead of copy, use dd.
The keys
| Keys | What they do |
|---|---|
yy | Copy (yank) the current line |
| p / P | Paste below / above |
dd | Cut the current line |
3yy | Copy three lines |
yw, y$ | Copy a word, or to the end of the line |
Vim calls copying yanking, which is why the key is y. Every delete also counts as a cut, so dd then p moves a line.
Whole lines paste as whole lines, on a new line. Part of a line pastes straight after the cursor.
Related
Want all of Vim, in order? Vim Scoops is a free game that starts at h j k l and builds up to macros.
Play the full game