Say I have this line of text in Vim:
(foo bar (baz) qux)
^
and my cursor is on the space between the words foo
and bar
, as indicated. I often find that, in situations like this, I want to delete the entire right-hand side of the outer parenthesized expression (that is, to the right of my cursor), while leaving the left-hand side intact. That is, I'd like to end up with:
(foo)
Usually, I’d accomplish this with dt)
(“delete until )
”), but the addition of a nested parenthetical complicates things: That command would leave me with (foo) qux)
. I could also use d2t)
, but I’d prefer not to have to manually count the number of nested parentheses. I could also use di)
, but that deletes the entire text inside of the parentheses, leaving me with ()
.
Is there a Vim motion with the balance-awareness of the i
- and a
-modified motions that is also relative to the current cursor position?
You can use the ])
motion with d
.
d])