← All lessons

6. Copying And Pasting

Step 2 of 7

Yanking and putting lines

In Vim, there are two keys to remember — y for yanking, and p for putting. We’re going to explore a number of ways to use the y and p keys in this lesson, but to kick us off, let’s try one of the simplest yank/put sequences possible: yanking a line with yy and then putting it into the buffer with p.

Give it a go in the editor. yy yanks the current line under the cursor. p will then put the yanked text onto the next line. You only need to yank the text once, then you can put it as many times as you like.

(Note: both yy and p accept counts — if you’re feeling adventurous, you can yank the line, then put it 5 times with 5p!)

Loading editor…