Learn Vim / How to Edit Text Inside Quotes in Vim

How to Edit Text Inside Quotes in Vim

The answerPress ci" — change inside quotes. It finds the quotes on the line even if the cursor isn't between them yet.

Try it on a real buffer

With the cursor anywhere on line 1, press ci" to change everything inside the quotes, type exactly hello, world then Esc.

greeting = "wrong message"
print(greeting)

Canonical solution: ci" hello, world Esc · par: 16 keystrokes (vimgolf rules — every keypress counts).

Why it works

ci" finds the quotes on the current line even if the cursor isn't inside them yet. The family is huge: i" / a" (inside / around quotes), i( , i{ , i[ , it for HTML tags…

Variations

KeysWhat it does
ci"change inside double quotes
ci'change inside single quotes
di"delete inside quotes
yi"copy inside quotes
ci( ci{ ci[same idea for brackets

Reading about keystrokes doesn't build keystrokes. Try this in a real vim buffer right now — the “Fix the string” mission takes about a minute.

Practice free — no signup →

Keep going