Copy and move text
The technique
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.