I have the following situation a lot, where I always end up having to yank two things in a row: For example, I want to yank a function call:

func(a, b)

Okay, here I can go to f and press vf).

But when the call is nested, this does not work anymore:

func(gunk(a), b)

Here I always end up going to for example b, doing da(, then move to where I want to paste it, then move back to func, do diw and move AGAIN to where I pasted (gunk(a), b).

Instead, I would like to do vi( to select (gunk(a), b) and then somehow extend the selection to the left by one word, so and up with the complete func(gunk(a), b) as the selection.

Is there a way to do that which does not involve writing a custom function to add to the .vimrc?

2 Answers 2



func(gunk(a, b))

with the cursor on the f of func, I would press y% or d%. The % command jumps between matching pairs (roughly; depending on configuration, optional plugins that ship with Vim, etc.), but it also first finds an opening pair if not already on one. That means v% in this situation covers all of func(gunk(a, b)), as desired, and y% or d% yanks or deletes the desired text.


You can do:


f( moves the the first parenthesis

% moves to the matching parenthesis

Another way if your are at b and to follow your idea is:


va( select (gunc(a, b))

o switch the cursor in front od the selection

b extend it to func(gunc(a, b))

  • Makes sense! Thanks. Oct 21, 2022 at 17:46
  • 1
    vabob is enough, not sure why bw, and the first line looks a bit odd (v Space? f(%`?)
    – D. Ben Knoble
    Oct 21, 2022 at 19:36

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.