Title here
Summary here
Text objects in Vim are essential for anyone looking to enhance their editing efficiency. They allow you to quickly select, modify, or manipulate blocks of text based on structural units such as words, sentences, paragraphs, and various enclosures.
Word (aw
, iw
):
aw
(a word): Selects a word and the space following it.iw
(inner word): Selects just the word under the cursor, without any surrounding whitespace.Sentence (as
, is
):
as
(a sentence): Selects a sentence and the space following it.is
(inner sentence): Selects the sentence without surrounding space.Paragraph (ap
, ip
):
ap
(a paragraph): Includes the paragraph and the blank line following it.ip
(inner paragraph): Selects just the paragraph without any trailing blank lines.Quotes (a"
, i"
):
a"
(a quote): Selects text including the quotation marks.i"
(inner quote): Selects text inside the quotation marks, excluding the quotation marks themselves.Blocks (ab
, ib
for brackets; a{
, i{
for braces; a(
, i(
for parentheses):
ab
or a(
: Selects a block of text including the surrounding parentheses.ib
or i(
: Selects only the text inside the parentheses, excluding the parentheses themselves.Tags (at
, it
for HTML/XML tags):
at
: Selects a tag block including the tags.it
: Selects only the content inside the tags, excluding the tags themselves.Text objects can be combined with various Vim commands to perform specific edits:
daw
deletes a word and the space following it.cis
changes the content of a sentence.yap
yanks a paragraph including the trailing blank line.c
(change), d
(delete), or v
(visual select) to enhance their utility..
(the repeat command).vim-textobj-user
, which allows for more tailored editing experiences.