How to delete from the cursor to the end of a parenthetical expression in Vim?

You can use the ]) motion with d.

d])

mxF(%d`x

Breaking it down:

mx

Set a mark x (pick whatever letter you like)

F(

Find previous ( character

%

Jump to matching )

d`x

Delete from here to mark x

That works for your specific case; I'm not sure how general it is. If the previous ( is not on the current line, use ?(<return> rather than F(.

EDIT:
I didn't mention d]) because I didn't know about it.

My solution won't work for this case:

( (before) foo (after) )
              ^

because it jumps back to the nearest (, not the nearest enclosing (.

Tags:

Vim

Editor

Motion