how to move to the next enclosing brackets in VI

Can't think of anything easier than /{

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


For the next enclosing brace do ]}, but in your example you are looking for the previous. In that case try [{.


You place your cursor on the opening or closing bracket of which you want to find the matching bracket and then use %. This will lead you to the matching braces.


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.

Tags:

C++

Vi

Vim