Replace Text Enclosed in Quotes or Brackets in VIM

This command, to change text enclosed between quotes/double quotes/any type of brackets, can be really time saving:
Say you have this code:

void f() {
    some_code_here();
    and_maybe_more_code();
    return;
}

Place the vim cursor anywhere inside the function, and (in command mode) type ci{ (meaning: Change Inner block enclosed between curly brackets).
The code within the brackets (In this case, the whole body of the function) will be deleted, and you’ll find yourself in insert mode where you can type the new code.

Try it, you’ll love it ;-)

Leave a Reply