Checkpoint: move and edit in real files

0 of 3

The technique

Your textVim mode: Normal
Delete the UK rate and make Belgium cost 595. Before: nl: 495 / be: 695 / uk: 1495. After: nl: 495 / be: 595.

The UK was the last line, so after dd the cursor is on the line above it. W jumps to the price and r5 replaces its first digit.

Keys in this lesson

cw
Change to the end of the word.
dd
Delete the line.
r
Replace one character with the next one you type.
o
New line below.
O
New line above.
yy
Copy the line.
p
Put after the cursor, or below the line.

Before this lesson: The other lessons of Editing foundations.

More about this lesson

Make three or four changes in each of three real files, with the moves and edits of this module.

You choose the commands. Move a line or two at a time, or jump with a line number and G. Then pick the edit that fits: x or r for one character, cw for a word, dd or cc for a whole line, o or O for a new one, and yy with p for a copy. 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 23

We've stopped shipping to the UK, so delete its rate. Free shipping starts at 6000 now, Belgium costs 595, and the carrier is carriers.dhl. You can use any commands.

Your textVim mode: Normal

Make it look like this

import { carriers } from "./carriers.js";

// Shipping rates in cents, by country. Free above the threshold.
export const FREE_SHIPPING_ABOVE = 6000;
export const RATES = {
  nl: 495,
  be: 595,
  de: 795,
};
export const CARRIER = carriers.dhl;

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.