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
cis 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 andci`for backticks - Use
ca"to change around the quotes, deleting the quote characters as well di"deletes inside quotes without entering insert modeyi"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