Step 4 of 6

Helix's various text objects

Helix’s various text objects

Now that we understand the distinction between inner and around, let’s explore what match mode can select.

Each of the text objects below has an inner and an around variant. If you read (, that means you can use mi( for the inner variant and ma( for the around variant.

  • ( — text captured by parentheses — ) also works
  • [ — text captured by square brackets — ] also works
  • { — text captured by curly braces — } also works
  • < — text captured by angle brackets — > also works
  • " — text captured by double quotes
  • ' — text captured by single quotes
  • ` — text captured by backticks
  • w — a word
  • W — a WORD (anything up to the next whitespace)
  • p — a paragraph

There’s a lot of them! Thankfully, they are mostly intuitive — if you’re targeting a quoted string, you use ", and if you’re targeting the text inside some parentheses, you use (. When pairs are nested, match mode picks the closest one around the cursor.

Let’s practice. In the editor, you’ve got some text that is full of places to use these text objects. Work through the checklist below, combining them with the actions we learned earlier.

  1. Select inside the square brackets Put your cursor inside the [ ] pair on line 3, then type mi[.
  2. Delete around the single quotes Move inside 'value' on line 4, type ma', then d — the quotes go too.
  3. Select inside the innermost parentheses Move onto the word parentheses on line 5 and type mi( — the closest pair wins.
  4. Select a whole paragraph Move into the last paragraph and type mip.
Select inside the square brackets Put your cursor inside the [ ] pair on line 3, then type mi[.

Next: Delete around the single quotes

Loading editor…