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!

  1. Navigate to each green target across the code snippet.
  2. Use the motions and techniques learned in this lesson to land accurately on each target.
  3. See how fast you can complete 10 targets.
0/10
1
const itemA = { id: 1, name: "Alpha" };
2
const itemB = { id: 2, name: "Beta" };
NORMAL
00:00