Reputation: 1471
Let say I have a block of code like this:
await store.dispatch(getLicensesThunk('content', submission))
And I want to delete everything inside the getLicensesThunk
excluding the parenthesis, what command should I use?
await store.dispatch(getLicensesThunk())
I currently use d%
for this, but it will delete the parenthesis as well, which is not something I want.
await store.dispatch(getLicensesThunk)
Upvotes: 0
Views: 423
Reputation: 196476
d%
can't do what you want because it is "inclusive", which means that it includes the characters at the beginning and end of the motion and therefore that it will swallow your parentheses.
Vim has a special kind of motion that can be used after an operator called "text objects". They are described under :help text-object
, which is one of the most mind-blowing sections of the built-in documentation.
The one you are looking for is :help i(
for "inner parentheses":
di(
Upvotes: 5
Reputation: 72629
Use di(
to delete everything inside parentheses. This also works for double quotes (di"
) and a few more paired characters.
The cursor can be anywhere between the parentheses.
Upvotes: 1