Protect a useful copy

0 of 3

The technique

Your textVim mode: Normal
Copy the heading, delete the obsolete line, then put the heading. Before: Heading / obsolete / body. After: Heading / body / Heading.

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.

Guides on this topic

Exercise 1 of 3

0keys

par 13

Copy the useful note, discard the obsolete note, and place the copy immediately below its source. Preserve the archive and footer.

Your textVim mode: Normal

Desired result

// Review dates
// 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.