Step 5 of 5

4. Basic Editing

Changing within special characters

Now, it’s not often that we want to just delete the content within special characters. Usually, we want to change the content — as in, get rid of the old stuff and put something new in its place.

Luckily, Vim has commands that help us. Recall that di" deletes inside the current quoted content. ci" will also delete inside the current quoted content, but it’ll drop you into insert mode right afterward. So, you can type ci", then just start typing the replacement text.

The mnemonic here is “change inside something

Of course, this works for parentheses, braces, and square brackets too. Work through the checklist below to try it out.

  1. Change inside the quotes Put the cursor inside the quoted string — you'll land in insert mode when you type ci".
  2. Type a replacement, then return to normal mode Type some new quoted content, then hit Escape.
  3. Change inside the parentheses Move inside the ( ) pair and type ci(.
  4. Type another replacement, then return to normal mode Fill in the new parenthesized text, then hit Escape.
Change inside the quotes Put the cursor inside the quoted string — you'll land in insert mode when you type ci".

Next: Type a replacement, then return to normal mode

Loading editor…