Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Vim fast way to modify method arguments

Tags:

vim

vi

One of the most common operation with source code is to modify the method arguments. Given a method argument list like this:

("argument1","argument2","argument3")

I wanna know how to deal with following operations(I use | here as a cursor position):

  1. When cursor inside a quotes, and you wanna delete the contents inside the quotes. like:
    "ar|gument1" to "|"
  2. same as the first one, but delete the quotes.
  3. delete all the things in bracket. ("argument1","argument2","argument3") to (|)
like image 923
Sawyer Avatar asked Jan 20 '23 04:01

Sawyer


1 Answers

Try these commands:

  1. di" (mnemonic: delete iniside ")
  2. da" (mnemonic: delete around ")
  3. di( or dib (mnemonic: delete inside () pair)

if you want to change the values (i.e. delete and remain in insert mode), use c instead of d.

For more information, and a lot of other possibilities, check :help text-objects.

like image 190
Matteo Riva Avatar answered Jan 25 '23 17:01

Matteo Riva