Text Objects

Vim knows about text objects. A text object is a part of text, such as word, sentence, block (block of text between brackets), or paragraph. You define them by pressing w, s, b, or p. Vim knows about one text object related specifically to markup languages - a tag. A tag corresponds to a pair HTML/XML element.

Vim distinguishes between the inner part of a tag, and the whole tag including the surrounding markup. Vim can also select a text enclosed in quotes, or jump the cursor between left or right sharp brackets. Get inspired by the following few useful examples:

commandhow to rememberdescription
it inner tagtext placed inside XML element
at all tagsame as it + the pair of surrounding tags
2it 2 x inner tagselect the inner text of the parent element (including the current tag)
2at 2 x all tagselect the whole parent element (including the current and the parent tags)
f> find >selects the text to the end of the closing tag, including '>'
t< find to >selects the text to the end of the closing tag, without '<'
F< find < backwardselects the text from the beginning of the tag, including '<'
T< find to < backwardselects the text from the beginning of the tag, without '<'
a" a stringselects the text including the surrounding quotes, such as XML attribute
i" a stringselects the text without the surrounding quotes, such as text of an XML attribute