Step 2 of 7

Yanking and pasting lines

Yanking and pasting lines

There are two keys to remember: y for yanking, and p for pasting. We’ll explore a number of ways to use them in this lesson, but to kick us off, let’s try the simplest yank/paste sequence possible: yanking a whole line and pasting it back into the buffer.

Remember that in Helix, every action applies to the current selection. So there is no special “yank a line” command — you select the line with x, then y yanks whatever is selected. p then pastes the yanked text after the selection. Because a line selection ends with a newline, the copy lands on the line below.

You only need to yank the text once, then you can paste it as many times as you like — and p accepts a count.

Work through the checklist below.

  1. Select and yank the target line Move to the Select me line (3gg gets you there), press x to select it, then press y.
  2. Paste it five times Since p accepts a count, 5p pastes all five copies in one go — or just press p five times.
Select and yank the target line Move to the Select me line (3gg gets you there), press x to select it, then press y.

Next: Paste it five times

Loading editor…