Protect a useful copy
The technique
After dd, a plain p would put obsolete. Register 0 still holds the copy.
Keys in this lesson
- "0p
- Put your last copy, even after a delete.
- "_dd
- Delete a line without replacing your copy.
- "ayy
- Copy the line into register a.
- "ap
- Put from register a.
Before this lesson: Copy and move text.
More about this lesson
Keep copied material across unrelated deletions and choose a named register.
Yanking also fills register 0; a later deletion replaces the unnamed register but not that last yank. "0p puts the last yank. "_dd discards a line without replacing your copy. "ayy copies a line into named register a, and "ap puts it. Lowercase a replaces that named register; uppercase appends and is outside these exercises.
Example
Copy a heading with yy, delete an obsolete line with dd, then use "0p to put the heading instead of the deleted line.
Use Reset to try again.