Step 2 of 7

6. Copying And Pasting

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.

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 — and both yy and p accept counts.

Work through the checklist below.

  1. Yank the target line Move to the Use yy to yank me line (3G gets you there), then press yy.
  2. Put it five times Since p accepts a count, 5p puts all five copies in one go — or just press p five times.
Yank the target line Move to the Use yy to yank me line (3G gets you there), then press yy.

Next: Put it five times

Loading editor…