Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to replace text between quotes in vi

Tags:

vim

vi

Say I have this line of code:

$query = "SELECT * FROM table";

Is there a command in vi/vim which can instantly delete everything between quotes and position the cursor between them so I can start typing?

like image 921
Nikola Avatar asked Sep 26 '22 20:09

Nikola


People also ask

How do you surround words with a quote in Vim?

press q and q for recording into q register (we use "q" as shortcut to remember "quotes"). press a then press ' again to surround the word with quotes.

What is CI in Vim?

ci (change inside) and variants thereof are very useful commands for me. ci" - change inside double quotes. ci) - change inside curved brackets. ci} - change inside curly brackets.


1 Answers

Use ci", which means: change what inside the double quotes.

You can also manipulate other text objects in a similar way, e.g.:

  • ci' - change inside the single quotes
  • ciw - change inside a word
  • ci( - change inside parentheses
  • dit - delete inside an HTML tag, etc.

More about different vim text objects here.

like image 217
Eugene Yarmash Avatar answered Oct 23 '22 07:10

Eugene Yarmash