Checkpoint: brackets, blocks and lines

0 of 3

The technique

Your textVim mode: Normal
Empty the inner object and keep the outer one. Before: server: { port: 3000, proxy: { "/api": "http://localhost:8000" } }. After: server: { port: 3000, proxy: {} }.

f{ lands on the outer bracket and ; on the inner one. From there di{ empties the inner pair. Inside the outer pair, it would empty that one instead.

Keys in this lesson

ci(
Change the text inside round brackets.
ci{
Change inside curly brackets.
%
The matching bracket.
d%
Delete to the matching bracket, brackets included.
dap
Delete the paragraph and a blank line.
J
Join the next line to this one.
>>
Indent the line.

Before this lesson: Text objects for brackets, %, deleting to a search, registers, paragraphs and the jump list.

More about this lesson

Make three changes in each of three real files: an API module, a config and a test.

You choose the commands here. Look at the shape of the code first: a change inside brackets is ci( or di{, a call with nested brackets goes with d%, a block between blank lines is a paragraph, and J joins a line that was split. Help is still there if you need it, and your result notes whether you used it.

Example

Before you start, read the task and find every line that changes. Check the whole result when you're done.

Try without hints first. Open help if you need it.

Guides on this topic

Exercise 1 of 3

0keys

par 36

The API knows the customer from the session and pages by itself now: make the query just { limit: 50 }. It drops drafts too, so remove the .filter(…) call. And cancelling is a PATCH now, not a POST. You can use any commands.

Your textVim mode: Normal

Make it look like this

import { request } from "./http";

// Orders for the account page, newest first.
export function listOrders(customerId) {
  return request("GET", "/orders", { limit: 50 })
    .then((response) => response.json())
    .then((body) => body.orders);
}

export function cancelOrder(orderId) {
  return request("PATCH", `/orders/${orderId}/cancel`);
}

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.