Vim Text Objects Mastery
Advancedv1.0.0
Master Vim text objects for precise, semantic text selection and manipulation — inner/around words, quotes, brackets, paragraphs, tags, and custom Treesitter objects.
Content
Overview
Text objects are Vim's most powerful editing concept. They let you operate on semantic units of text — words, sentences, quoted strings, code blocks — without manually positioning your cursor. Combined with operators (d, c, y, v), they form the "verb + noun" editing language.
Why This Matters
- -Precision — select exactly the text you want, regardless of cursor position
- -Speed —
ci"is faster than navigating to quotes manually - -Repeatability — text object operations work perfectly with
.(dot repeat) - -Composability — any operator works with any text object
Built-in Text Objects
Word Objects
Quote & Bracket Objects
Block & Paragraph Objects
The Inner vs Around Pattern
| Prefix | Meaning | Includes Delimiters? |
|---|---|---|
| `i` | inner | No — just the content |
| `a` | around (a/an) | Yes — includes delimiters/whitespace |
Practical Workflow Examples
Changing Function Arguments
Replacing a Quoted String
Deleting an HTML Tag
Yanking a Code Block
Treesitter Text Objects (Neovim)
Best Practices
- -Prefer text objects over visual selection —
ciwoverbvec - -Use `i` (inner) for changing — keeps delimiters intact
- -Use `a` (around) for deleting — removes delimiters too
- -Learn in pairs: always learn both
iandavariants - -Install Treesitter text objects for language-aware selections
Common Mistakes
- -Using visual mode + manual selection instead of text objects
- -Forgetting that cursor can be anywhere inside the text object
- -Confusing
i(inner) witha(around) when deleting vs changing - -Not installing Treesitter text objects for code-aware editing
FAQ
Discussion
Loading comments...