Vim – “Change in quotes” trick

Changing quotes in Vim

One of my most used Vim (or IDEAvim in Intellij) commands when I’m editing code is ci”.
I’ve talked before¬†about text objects in Vim like environments and even mentioned how I use c (change) on the command line in vi mode. I think the Vim verb to “change” offers a lot of power that’s lacking in other editors but I just want to talk about ci” today.

What you might not know

Hopefully if you read the last post you’ve adopted ci” in your daily usage, however you might not have realised that this also jumps to the first set of quotes on a line if you’re not currently in quotes. Example:
System.out.println("My printed statement");
Imagine your cursor is currently on the S. (Remember: ^ goes to start of line). If you do ci” then your cursor will jump to the quotes, delete the contents and enter into insert mode ready to type:
System.out.println("");

Leave a Reply

Your email address will not be published. Required fields are marked *