how to move to the next enclosing brackets in VI


Question

Are there any shortcuts to move to the next enclosing brackets. For ex:

int func()
{

 if(true)
 {//this point

   for(int i=0;i<10;i++)
   {//need to jump from here to

    //blah blah blah

   }

 }
}

I can move to the beginning of a function using [[ but not sure how to move to the next enclosing brackets. Thanks for any info...

1
14
10/2/2009 2:30:04 PM

Accepted Answer

Can't think of anything easier than /{

[{ will go to an unmatched one, but that isn't what you want.

15
10/2/2009 2:31:39 PM

Put the cursor on one bracket and hit the percent key.

Also setting the 'showmatch' option makes the cursor jump to the matching opening bracket when you type the closing bracket.

Adding a declaration like this:

set matchpairs+=<:>

Will add angle brackets to the standard list of match pair brackets.


Licensed under: CC-BY-SA with attribution
Not affiliated with: Stack Overflow
Icon