Command-B | Balance block |
Balance selects text inside ( ), { }, [ ] and < > pairs, including the brackets; press multiple times to expand to outer levels. This function is useful for determining whether a particular block of code is properly enclosed in brackets, you can often use it to pinpoint a missing paren when the error message produced by the compiler isn't as helpful.
Place a cursor anywhere inside a parentheses pair and press Command-B.
The selection expands to enclose the parentheses in the if statement. Press Command-B again.
This time the curly braces of the enclosing block are balanced. Balance again.
This time you hit the outermost block.
You can also balance by double clicking one of the ( ), { }, [ ], " " and ' ' pairs. Eddie will expand the selection to the matching bracket or quote pair. Note that unlike hitting Command-B, when balancing using a double-click, the balanced brackets or quotes themselves are not selected. In our previous example, if we double-click the opening parentheses of the if statement, we get:
Double-click balancing can be nicely used in combination with the Balance command (Command-B).
By using the Command-double-click on a line with #if, #ifdef, #else and #endif you may select text enclosed in an #ifdef block (this feature is part of the IfdefBalancer plugin). You may also use the "Balance #ifdef" menu item from the Edit menu.
Command-Double-Click | Balance #ifdef |
Command-Option-B | Balance #ifdef |
Read more about the various ways #ifdefs can be balanced in the Ifdef balancer section.