Skip to content

Vim text objects guide

Louis Maddox edited this page Oct 7, 2022 · 1 revision

Text objects are outlined in Vim Text Objects: The Definitive Guide.

An example is ci( which changes inside brackets or ci" which changes inside double quotes.

There's also ca( which changes around brackets etc.

The practical difference is that changing inside something (such as a word, ciw) will let you overwrite that word (immediately laying the cursor where the word was) whereas changing around something (like a word, caw) will let you also remove and replace the whitespace.

For things like brackets:

  • ca( is the same as sw (insert mode/delete word) for a single word in brackets from the first bracket (note that ca( works anywhere in the bracketed open interval
  • ci( is the same as

Note that just like d and these other commands, the deleted characters go to the clipboard buffer.

You can also have... Sentences like this! And so on.

Placing the cursor on the letter n of Sentences:

  • cas deletes the word Sentences! and the whitespace before And, placing the cursor in insert mode at the start of the next sentence.
You can also have... |And so on.
  • cis enters insert mode in between the whitespace that enclosed the sentence
You can also have... | And so on.

The same principle of putting the cursor "instead of" and "after what was" the text object applies to paragraphs, and likewise the cursor can be anywhere within the paragraph to use this command.

You can't use the ci" for quotation/brackets/etc across multiple lines.

Clone this wiki locally