vimtricks.wiki Concise Vim tricks, one at a time.

How do I quickly replace the text inside quotes without manually selecting it?

Answer

ci"

Explanation

The ci" command deletes everything inside the nearest pair of double quotes and drops you into insert mode, ready to type the replacement. This is one of Vim's most-used text object commands and works regardless of where your cursor is within the quoted string.

How it works

  • c is the change operator (delete and enter insert mode)
  • i" is the "inner double quote" text object — it selects the content between the quotes, excluding the quotes themselves

Example

Given the text with the cursor anywhere on the line:

const name = "John Doe";

Pressing ci" removes John Doe and places you in insert mode between the quotes:

const name = "|";

Type Jane Smith and press <Esc>:

const name = "Jane Smith";

Tips

  • Use ci' for single quotes and ci` for backticks
  • Use ca" to change around the quotes, deleting the quote characters as well
  • di" deletes inside quotes without entering insert mode
  • yi" yanks (copies) the text inside quotes
  • In Vim 8+, ci" searches forward on the current line if the cursor is not already inside quotes
  • Combine with . to repeat the same replacement inside other quoted strings

Next

How do I edit multiple lines at once using multiple cursors in Vim?