Copy and move text

0 of 2

The technique

Your textVim mode: Normal
Move the first line below the second. Before: milk / eggs / bread. After: eggs / milk / bread.

dd keeps the deleted line, and p puts it below the line the cursor is on now.

Keys in this lesson

yy
Copy the line.
p
Put after the cursor, or below the line.
P
Put before the cursor, or above the line.
yiw
Copy the word.
dd
Delete the line.

Before this lesson: Operators and line boundaries.

More about this lesson

Predict where characterwise and linewise copies will be put.

y copies; d removes and copies. yy and dd are linewise: p puts their content below the current line, P above. A characterwise copy such as yiw is put after the cursor with p or before it with P. The unnamed register can change after another deletion.

Example

With the cursor on a first checklist line, yy then p duplicates that line below. A later dd moves a line instead of leaving the original.

Use Reset to try again.

Guides on this topic

Exercise 1 of 2

0keys

par 3

Move the first step below the second; keep the archive last.

Your textVim mode: Normal

Desired result

// Publish note
// Review dates
// Keep archive

Yours

Par

Keyboard shortcuts
Ctrl+Enter
Check the result
Ctrl+Alt+U
Undo the last change
Ctrl+Alt+H
Show the next hint
Ctrl+Alt+R
Reset the exercise
Ctrl+Alt+P
Previous exercise
Ctrl+Alt+N
Next exercise
Enter
After a solve: the next step

Ctrl+Alt shortcuts leave Vim's own keys alone. On a Mac, Control and Option.