Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

In vim, is it possible to select content between the brackets inclusive of the brackets similar to

yi{ yi(

But I want to include the brackets

share|improve this question
up vote 0 down vote accepted

You can move the cursor over one bracket, and do vf{ or vf( to bring you into visual mode and then select everything until (and including) the bracket.

share|improve this answer
Actually, this will end up selecting only the opening brace. If you're on top of the opening brace, f{ will move you to the closest opening brace, which you're already on. What you probably want is v% which will move you to the matching brace and can be used on either side. – Michael Mior Nov 23 '14 at 5:32

Yes. Use a instead of i, as



:help a{
:help a(

and more generally,

:help text-objects
:help 04.8
share|improve this answer

Does f{v% or f(v% do what you want? It moves your cursor to the next { or (, enters you into visual mode, and then moves your cursor to the corresponding closing } or ). If you're already past the scope you want to select, you can use a capital F. Works just as well to jump to the closing } or ) first, too -- f}v%.

Once you have what you want selected, you can y, d, x, etc. it. The % command works multi-line, too, so you can use this technique on large blocks of code if you wish (although f and F do not, so you have to start on either the first or last line).

EDIT: Better answer, seems to be exactly what you're looking for:


Replacing the i in your original command with a does exactly the same thing, except that it includes the '(' character. This is "yanking a block", whereas yi( is "yanking an inner block".

share|improve this answer
Thanks for pointing out the % command! – wdev Aug 31 '12 at 13:54

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .