Checkpoint: search and edit in real files

0 of 3

The technique

Your textVim mode: Normal
Change basket to cart in both messages. Before: title: "Checkout" / added: "It's in your basket" / removed: "It's out of your basket". After: title: "Checkout" / added: "It's in your cart" / removed: "It's out of your cart".

The search takes you to the first one without counting lines, and n finds the next. cw changes the word from its start.

Keys in this lesson

/text
Search forward. Press Enter to go.
n
Next match.
cw
Change to the end of the word.
ci"
Change the text inside double quotes.
x
Delete one character.
A
Insert at the end of the line.

Before this lesson: Editing foundations, the word and quotation lessons, and the search lessons.

More about this lesson

Make three or four changes in each of three real files. Most of them are a search away.

You choose the commands. Search for what changes, and when the same word changes twice, n takes you to the next one. Try without hints first, and open help if you need it.

Compare your whole result with the target before you finish.

Guides on this topic

Exercise 1 of 3

0keys

par 54

Shipping to the UK costs 1750 now, and customs are charged separately. Update what the UK test expects, delete the comment about customs, and rename the first test to costs nothing above the threshold. You can use any commands.

Your textVim mode: Normal

Make it look like this

import { describe, expect, it } from "vitest";
import { shippingCost } from "./shipping.js";

describe("shippingCost", () => {
  it("costs nothing above the threshold", () => {
    expect(shippingCost({ country: "NL", total: 6000 })).toBe(0);
  });
  it("charges 495 in the Netherlands", () => {
    expect(shippingCost({ country: "NL", total: 1400 })).toBe(495);
  });
  it("charges 995 to the rest of the EU", () => {
    expect(shippingCost({ country: "DE", total: 2000 })).toBe(995);
  });
  it("charges more to the United Kingdom", () => {
    expect(shippingCost({ country: "GB", total: 2000 })).toBe(1750);
  });
});

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.