← All lessons

4. Basic Editing

Step 4 of 5

Deleting within special characters

A few characters are normally intended to “capture” things. For example: ", (), {}, and [] are typically intended to delimit something. In written language, quotes are used to capture what a person is saying, and brackets are used to insert additional information into text. If you’re a software engineer, you will have also seen {} and [] used to capture chunks of code.

Vim understands these constructs. In Vim parlance, we have text objects representing the content that is grouped by certain characters. We can perform operations on them.

This is when most people start to glimpse at the true power of Vim, so hold on to your hats!

We can use di" in normal mode to delete everything inside quotes. We can similarly use di(, di{, and di[ to delete everything inside brackets, braces, and square brackets respectively. Note that you have to be inside the quotes/brackets/etc for these commands to work. The mnemonic here is “delete inside something

In the editor, we have some examples of these text constructs. Give the commands above a try!

Loading editor…