Optional: numeric changes

0 of 3

The technique

Your textVim mode: Normal
Add three to the count. Before: items: 7. After: items: 10.

Ctrl-a finds the first number at or after the cursor, so you do not have to move onto it first.

Keys in this lesson

Ctrl-a
Add one to the number at or after the cursor.
Ctrl-x
Subtract one.
3Ctrl-a
Add three.

Before this lesson: Counts and recovery.

More about this lesson

Add to or subtract from a number without changing the numbers near it.

Ctrl-a adds one to the number at or after the cursor on the line, and Ctrl-x subtracts one. It finds the number by itself, so you don't have to move onto it first. A count changes the amount, so 30 Ctrl-x takes 30 off. These exercises use plain whole numbers, because numbers like 0x1f follow their own rules. Check which number comes first on the line before you press it.

Example

From 7, Ctrl-a gives 8 and 3Ctrl-a gives 10. You never have to type the new number.

Use Start over to try again.

Guides on this topic

Exercise 1 of 3

0keys

par 1

Card payments that fail get a few more tries. Give them one more attempt.

Your textVim mode: Normal

Make it look like this

import { sql } from "../db";

// The payments the retry job picks up every ten minutes.
export function paymentsToRetry() {
  return sql`
    SELECT id, order_id, amount_cents FROM payments
    WHERE status = 'failed' AND attempts < 4
  `;
}

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.