Screen Too Small

This course material requires a larger screen to properly display the terminal and editor interfaces.

Please use a tablet, laptop, or desktop computer for the best learning experience.

You can continue browsing, but the experience will be significantly limited.

15/24

The Power of Text Objects

Estimated time: 6 minutes

🎯 Chapter 3: Text Objects Mastery

Welcome to the game-changing chapter! Text objects are what separate Vim masters from everyone else. Instead of carefully positioning your cursor and counting characters, you'll learn to operate on logical units of text - words, sentences, quotes, parentheses, and more.

What Are Text Objects?

Key Insight: Text objects let you operate on logical units of text without precise cursor positioning. Want to change what's inside quotes? Just use ci" anywhere inside the quotes. Want to delete a whole function? Use dap (delete a paragraph).

The magic formula: [operator] + [i/a] + [object]. Where 'i' means inside and 'a' means around (including delimiters).

What You'll Learn This Chapter

Lesson 1: Word Objects (iw, aw, iW, aW)

Master word and WORD objects. Learn the difference between iw (inner word) and aw (around word), and when to use each.

Lesson 2: Quote & String Objects (i", a", i', a')

Work with quoted strings efficiently. Change string contents, delete entire strings, or operate on string values in code.

Lesson 3: Delimiter Objects (i(, a(, i[, a[, i{, a{)

Master parentheses, brackets, and braces. Perfect for function arguments, array elements, and code blocks.

Lesson 4: Sentence & Paragraph Objects (is, as, ip, ap)

Work with larger text units. Edit documentation, refactor functions, and manipulate text blocks.

Lesson 5: Tag Objects (it, at)

Edit HTML/XML efficiently. Change tag contents, delete entire elements, or manipulate markup structure.

Lesson 6: Combining Text Objects with Operators

Practice using text objects with d (delete), c (change), v (visual select), and other operators.

The Inside vs Around Concept

Every text object has two versions:

  • i (inside/inner): Selects the content, excludes delimiters
    Example: ci" changes text inside quotes, keeps the quotes
  • a (around): Selects content AND delimiters
    Example: ca" changes text and removes the quotes too

This simple concept gives you precise control over your edits.

Pro Tip: Think in Text Objects

Stop thinking about cursor position and start thinking about text objects. Instead of:

  • • "Move cursor to start of word, then delete to end" → Just use diw
  • • "Find opening quote, delete to closing quote" → Just use di"
  • • "Select everything between parentheses" → Just use vi(

Text objects work from anywhere within the target - no precise positioning required!