Single-character/single-line operations are inefficient when editing structured text (quotes, brackets, paragraphs). Manually counting or searching to select delimited blocks is error-prone.
Text objects allow selecting delimited content (words, sentences, paragraphs, quoted strings, brackets) with two-character commands: <action>i<object> (inside) or <action>a<object> (around).
Pattern: <action>a<object> and <action>i<object>
- action: any operator (
ddelete,yyank,vselect) - i: inside (content only)
- a: around (including delimiters)
Common objects:
| Object | Meaning |
|---|---|
w | word |
W | WORD (whitespace-separated) |
s | sentence |
p | paragraph |
" | double quotes |
' | single quotes |
) or b | parentheses |
] | brackets |
} | braces |
t | tags (like <html>) |
ci"changes inside quotes without deleting the quotesda"includes the quotes in the deletionv2i)selects the inner two parentheses groups- Count prefixes work:
d2i(deletes two nested groups
- Visual mode doesn’t need an action — just
vi"works - Nested quotes: counts work (
ci""— inner pair in"foo"bar") - Objects are motion-compatible —
yworks same asd(yanks)
- Vim Modes — Requires Visual or Normal mode
- Survival Commands — Use operators like
d,y - Visual Selection — Text objects extend selection
- Repetition — Can repeat text object operations