Mission 18 / 52• Basic Operators

Copy/Paste Lines

In Vim, copying is called **yanking** (`y`), and pasting is called **putting** (`p`).

Any text you delete with `d` or `x` also goes into the default register, meaning you can cut and paste with `dd` then `p`!

Yank and put

  • yyyank (copy) the current line
  • pput (paste) clipboard content BELOW the cursor
  • Pput (paste) clipboard content ABOVE the cursor
1
const itemA = { id: 1, name: "Alpha" };
2
const itemB = { id: 2, name: "Beta" };

On `itemA`, press `yy`, move down to `itemB`, and press `p`. A duplicate line appears immediately below!

Now it's your turn!

0 / 4 tasks complete0.0s / 16s par0 / 16 par

Practice this lesson's commands. Each task checks your technique and the result, not just your cursor position. Take your time.

Task 1: Copy alpha(); with yy and paste it below beta(); with p.

Expected result
alpha();
beta();
alpha();
Show hint

Use yy, j, then p.

1
alpha();
2
beta();
jkscroll•ggGtop/bottom•Tabnext example•Enterstart•qstop•Ctrl+kCtrl+jprev/next