Match nested delimiters

0 of 2

The technique

Your textVim mode: Normal
Jump from the first opening bracket to its partner. Before: outer(inner(value)). After: outer(inner(value)).

% lands on the last bracket, which is the real partner. It skips the first closing bracket it meets.

Keys in this lesson

%
The matching bracket.
d%
Delete to the matching bracket, brackets included.

Before this lesson: Choose the whole pair.

More about this lesson

Jump to a bracket's real partner instead of the next bracket that looks the same.

On a bracket, % moves to its partner, even through nested pairs. Anywhere else on the line, it uses the next bracket after the cursor. d% deletes from the cursor to that partner, brackets and all. A character search like f) just finds the next ), so it can stop at the wrong one.

Example

On the first opening bracket in outer(inner(value)), % jumps to the very last closing bracket and skips the inner one.

Use Start over to try again.

Guides on this topic

Exercise 1 of 2

0keys

par 8

The search fires on every key. Wait 300 milliseconds: add it as the second argument of setTimeout.

Your textVim mode: Normal

Make it look like this

import { searchProducts } from "../api/search";

// Searches as the customer types, but waits until they pause.
export function onQueryChange(input, render) {
  clearTimeout(input.timer);
  input.timer = setTimeout(() => {
    searchProducts(input.value).then(render);
  }, 300);
}

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.