Surround
A wrapping station for track 6's foil: ys wraps a noun (ysiw"), cs swaps the wrapping (cs'"), ds takes it off; opening brackets wrap loosely, closing ones tightly.
Monday after launch, 9:30 a.m. Taco Turbo's new menu page is yours, word for word. Your answer is a better one by lunch, and the edits are all wrappings: single quotes that should be double, names that need an <em>, brackets nobody needs.
Wrappings are track 6's foil. A plugin turns them into verbs.
Warm-up from earlier chapters
Two from earlier chapters, from memory, before the new idea. Two wrong tries show the answer.
A wrapping station
surround (vim-surround, by Tim Pope; built into several editors, see below) adds three verbs for the foil. ys wraps: ysiw" puts the word in quotes. cs swaps one foil for another: cs'" turns single quotes into double. ds takes the foil off and keeps the filling: ds( removes the brackets around you.
x = 'hi'x = "hi"name: Alname: "Al"": the word, wrapped.Swap the foil
Single quotes where the code uses double. cs'" from inside each string.
This exercise needs a keyboard. Read on, and play it at your computer.
Loose or tight, and labels
With brackets, the opening one wraps loosely and the closing one tightly: ysiw( gives ( word ), ysiw) gives (word). yss wraps the whole line. A tag works as the foil too, as in the tags lesson: ysiwt then the tag, or ysiw<em>, gives <em>word</em>. In Visual mode, S and the foil wraps the highlight.
Loose or tight?
You press ysiw( on foo. What does the line say?
Make up your mind
The design team wants new items marked. Brackets: ysiw) on new. Five minutes later, quotes instead: cs)". Ten minutes after that, nothing at all, the badge will do it: ds".
The first exercise of every lesson is free. Pro unlocks the rest, every track, for good.
See ProThis exercise needs a keyboard. Read on, and play it at your computer.
Take the foil off
Brackets and quotes nobody needs. ds and the character, from inside each pair.
The first exercise of every lesson is free. Pro unlocks the rest, every track, for good.
See ProThis exercise needs a keyboard. Read on, and play it at your computer.
The menu line
Two wrappings on one line: 'spicy' gets double quotes, and the two words Al Pastor get wrapped in <em>. The cursor is in spicy.
Stuck? Show a hint
The first exercise of every lesson is free. Pro unlocks the rest, every track, for good.
See ProThis exercise needs a keyboard. Read on, and play it at your computer.
The wrapping station, from memory
Press the keys.
The new menu page
Ten wrappings across the codebase: quotes to swap, wraps to add, wraps to take off.
The first exercise of every lesson is free. Pro unlocks the rest, every track, for good.
See ProThis exercise needs a keyboard. Read on, and play it at your computer.