Learn Practice Daily golf Reference
Text objects·Lesson 3 of 8·8 min·0/8 exercisesPro

Quotes

i" is a string's filling, a" the string in its foil; from before the quotes ci" takes the first string on the line, and i' and i` work the same way.

Scene

Tuesday, 11:40 a.m. Every item in menu.json gets a description, the line people read on the app before they order. The kitchen sends them over in a chat message; you put them in the strings.

Most lines in menu.json hold two strings: a key and its value. Today you find out which one a quote object takes.

From memory

Warm-up from earlier chapters

Two from earlier chapters, from memory, before the new idea. Two wrong tries show the answer.

Delete this dotted path and the space beside it.
press the keys…3 keys
1 of 2
Delete this dotted path and the space beside it.

The quotes are the foil

A string is a burrito whose foil is its two quotes. i" is the filling, the text between them; a" is the string in its foil, quotes included, plus the space after it (or, if there's none, the space before it: the same rule as aw). From anywhere inside the string, ci" replaces the text and keeps the quotes.

i"
toast("Order placed" + suffix, "success");
a"
toast("Order placed" + suffix, "success");
The filling, then the burrito in its foil: a" also takes the space after the closing quote.

The next one on the counter

If the cursor is before the first quote on the line, ci" reaches forward and takes the first string it finds. Handy at the start of a line, but in JSON the first string is the key: from the start of { "name": "Birria", … }, ci" changes name, not Birria. To reach the last string on a line, $ then F" puts you on its closing quote.

i"
{ "name": "Birria", "desc": "Beef stew" },
a"
{ "name": "Birria", "desc": "Beef stew" },
From the start of the line, both take the first string: the key.
Try it

Fill the descriptions

Three empty descriptions, each the last string on its line. Get into each one (or onto one of its quotes) and ci".

1 of 3Type Pork and pineapple where it's shown in green
1{
1 "menu": [
2 { "name": "Al Pastor", "desc": "" },
3 { "name": "Carnitas", "desc": "" },
4 { "name": "Birria", "desc": "" }
5 ]
6}
NORMALLoading the editor…1/30.0s1:1

This exercise needs a keyboard. Read on, and play it at your computer.

Check yourself

The gap between two burritos

1 { "name": "Birria", "desc": "Beef stew" },
NORMAL
Keys pressed: di"

The cursor is on the colon between "desc" and "Beef stew". You press di". What happens?

Pick an answer (or press its number), then watch the engine prove it.
Try it

Off the gap

The kitchen revised two descriptions. The first slip is made for you: di" with the cursor on a colon. Look at what it took, u, then land on a letter of the description and change it to Slow-cooked pork, crisp edges. Then Al Pastor's becomes Pork, pineapple, chilli, from wherever you are.

Stuck? Show a hint
Pro
The rest of this lesson is in Pro

The first exercise of every lesson is free. Pro unlocks the rest, every track, for good.

See Pro

This exercise needs a keyboard. Read on, and play it at your computer.

Other foils

Single quotes and backticks wrap strings too, and their objects work the same way: ci' for 'Menu', and ci` for a template string in backticks. The filling is everything between the two marks, ${…} and all.

Try it

Single quotes and backticks

The app's own strings: a title in single quotes, a template string, and an empty-list message. ci' and ci`; a line's first string can be changed from the start of the line.

Pro
The rest of this lesson is in Pro

The first exercise of every lesson is free. Pro unlocks the rest, every track, for good.

See Pro

This exercise needs a keyboard. Read on, and play it at your computer.

From memory

Quotes, from memory

Press the keys. The cursor is inside the string.

Change the text inside these double quotes.
scroll here, then press the keys3 keys
1 of 5
Change the text inside these double quotes.
Challenge

Wrong strings

Ten strings with the wrong text across the codebase. The cursor never has to reach the first letter.

Pro
The rest of this lesson is in Pro

The first exercise of every lesson is free. Pro unlocks the rest, every track, for good.

See Pro

This exercise needs a keyboard. Read on, and play it at your computer.

Boss round

The description pass

12:30. The kitchen's last messages: Garden Veggie's description is still TODO (it should say Beans and peppers), chiken is misspelled, the note becomes Prices before tax., and the allergens line becomes a short Ask us. Four strings, all of them values: never the first string on the line.

Stuck? Show a hint
Pro
The rest of this lesson is in Pro

The first exercise of every lesson is free. Pro unlocks the rest, every track, for good.

See Pro

This exercise needs a keyboard. Read on, and play it at your computer.

Extra practice optional

The chapter is done. These rounds keep going as long as you like: stop whenever it stops being useful.

Endless

Strings, endlessly

Endless wrong strings. Change inside.

Pro
The rest of this lesson is in Pro

The first exercise of every lesson is free. Pro unlocks the rest, every track, for good.

See Pro

This exercise needs a keyboard. Read on, and play it at your computer.