Use paragraph boundaries

0 of 4

The technique

Your textVim mode: Normal
Delete the first note and the blank line after it. Before: First note / still first / / Second note. After: Second note.

dip would keep the blank line. Only blank lines make paragraphs, so code braces don't count.

Keys in this lesson

}
Next blank line between paragraphs.
{
Previous blank line between paragraphs.
dip
Delete the paragraph and keep the blank line.
dap
Delete the paragraph and a blank line.

Before this lesson: Words and operators.

More about this lesson

Edit paragraphs, which in Vim are just text between blank lines.

Vim splits paragraphs at blank lines. ip is the paragraph's text and ap also takes the blank lines after it. } moves to the blank line after the paragraph and { to the one before it. Braces and indentation in code don't count: a function or a group of imports is a paragraph when blank lines surround it.

Example

With two notes and a blank line between them, dip deletes the current note and keeps the blank line. dap deletes the blank line too.

Use Start over to try again.

Guides on this topic

Exercise 1 of 4

0keys

par 3

Nothing calls legacyTotal any more. Delete the function and the blank line after it.

Your textVim mode: Normal

Make it look like this

import { sum } from "../lib/math";

export function itemsTotal(cart) {
  return sum(cart.items.map((item) => item.cents * item.quantity));
}

export function shippingFor(cart) {
  return itemsTotal(cart) >= 5000 ? 0 : 495;
}

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.