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 something you copied safe while you delete other text, or save it under a name.

Copying also fills register 0. A later delete or change replaces what a plain p puts, but register 0 keeps your last copy, so "0p still puts it. "_dd deletes a line without touching your copy. "ayy copies a line into register a and "ap puts it. A lowercase a replaces what's in that register. An uppercase A adds to it instead, but you won't need that here.

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 Start over to try again.

Guides on this topic

Exercise 1 of 3

0keys

par 15

Serve images from media.northwind.shop first, and keep the img host as the last fallback.

Your textVim mode: Normal

Make it look like this

import { pickHost } from "./pickHost";

// Image hosts, tried in order until one answers.
export const IMAGE_HOSTS = [
  "https://media.northwind.shop",
  "https://images.cdn-eu.example",
  "https://images.cdn-us.example",
  "https://img.northwind.shop",
];

export const imageUrl = (path) => pickHost(IMAGE_HOSTS) + path;

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
Start the exercise over
Ctrl+Alt+P
Previous exercise
Ctrl+Alt+N
Next exercise
Ctrl+Alt+K⌃⌥K
Show the keyboard shortcuts
Ctrl+Alt+F⌃⌥F
Turn focus mode on or off
Ctrl+Alt+S⌃⌥S
Open the editor settings
Enter
Go on to the next step after you finish

The Ctrl+Alt shortcuts don't clash with Vim's own keys. On a Mac, use Control and Option.