Quote Text Objects

Now that we have reviewed the common components of prose, let's look at text-objects that represent other groupings of text, which can be used to pin-point specific groups of text within sentences and paragraphs, as well as within programming code. In the first example, we look at quotes.

quotes
sequences of text contained within quotes, including double-quotes (""), single-quotes (''), or ticks (``)

Quotes are common in prose, as well as in programming languages, so the ability to pin-point those areas of text can be very convenient.

Let's take a look at a few examples to see how these work:

Selecting inside Quotes

Since there are 3 different types of quotes, let's go ahead and look at examples for each of them. The following buffer contains 3 lines, each with text surrounded in a different type of quotes. Let's move the cursor to each line then select inside the quotes. First, let's look at the double-quotes:

Initial Conditions
This·is·a·line·"with·quoted·text",
this·line·has·'single·quotes',
and·this·has·`backticks`·in·it
NORMAL
Top
1:1
 
Move the cursor
vi"
This·is·a·line·"with·quoted·text",
this·line·has·'single·quotes',
and·this·has·`backticks`·in·it
VISUAL
Top
1:32
 

First, unlike previous examples, although the cursor did not start inside the quoted text, it first jumped to the quoted text, then selected it. Next, as you might have expected, selecting inside the quotes selects the quoted text, but not the quotations marks themselves. This works similarly for single quotes:

Move the cursor (again)
This·is·a·line·"with·quoted·text",
this·line·has·'single·quotes',
and·this·has·`backticks`·in·it
NORMAL
50%
2:1
 
Move the cursor (again)
vi'
This·is·a·line·"with·quoted·text",
this·line·has·'single·quotes',
and·this·has·`backticks`·in·it
VISUAL
50%
2:28
 

And, finally, the ticks:

Move the cursor (again)
This·is·a·line·"with·quoted·text",
this·line·has·'single·quotes',
and·this·has·`backticks`·in·it
NORMAL
75%
3:1
 
Move the cursor (again)
vi`
This·is·a·line·"with·quoted·text",
this·line·has·'single·quotes',
and·this·has·`backticks`·in·it
VISUAL
75%
3:23
 

Selecting around Quotes

Following the previous examples, we will repeat that process for selecting around the text object, so we can see the differences:

Initial Conditions
This·is·a·line·"with·quoted·text",
this·line·has·'single·quotes',
and·this·has·`backticks`·in·it
NORMAL
Top
1:1
 
Move the cursor
va"
This·is·a·line·"with·quoted·text",
this·line·has·'single·quotes',
and·this·has·`backticks`·in·it
VISUAL
Top
1:33
 
Move the cursor (again)
This·is·a·line·"with·quoted·text",
this·line·has·'single·quotes',
and·this·has·`backticks`·in·it
NORMAL
50%
2:28
 
Move the cursor (again)
va'
This·is·a·line·"with·quoted·text",
this·line·has·'single·quotes',
and·this·has·`backticks`·in·it
VISUAL
50%
2:29
 
Move the cursor (again)
This·is·a·line·"with·quoted·text",
this·line·has·'single·quotes',
and·this·has·`backticks`·in·it
NORMAL
75%
3:23
 
Move the cursor (again)
va`
This·is·a·line·"with·quoted·text",
this·line·has·'single·quotes',
and·this·has·`backticks`·in·it
VISUAL
75%
3:25
 

The primary difference from selecting inside quotes from the previous examples is that both the quotation marks and the separating whitespace are included when selecting around the quotes.