Learn Vim / How to Delete Everything Inside Parentheses in Vim

How to Delete Everything Inside Parentheses in Vim

The answerWith the cursor inside (or on) the parentheses, press di( — delete inside parens.

Try it on a real buffer

Those arguments have to go. Move the cursor inside the parentheses (try f( to jump to the paren, then l), and press di( to delete everything inside them.

result = calculate(all, of, these, args, must, go)

Canonical solution: f( l di( · par: 5 keystrokes (vimgolf rules — every keypress counts).

Why it works

f{char} jumps forward to the next {char} on the line (; repeats the jump, F goes backward). di( / di) deletes inside the nearest enclosing parens.

Variations

KeysWhat it does
di(delete inside ( )
da(delete the parentheses too
ci(delete inside and enter insert mode
di{ di[ ditsame for braces, brackets, HTML tags

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

Practice free — no signup →

Keep going