Alt-B | Balance block |
Balance selects text inside ( ), { }, [ ] and optionally < > pairs, including the brackets; press multiple times to expand to outer levels. This function is usefull for determining whether a particular block of code is properly enclosed in brackets.
Place a cursor anywhere inside a parentheses pair and press Alt-B.
The selection expands to enclose the parentheses in the if statement. Press Alt-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 optionally < > pairs. Eddie will expand the selection to the enclosing brackets. Note that unlike hitting Alt-B, when balancing using a double-click, the balanced brackets themselves are not selected. In our previous example, if we double-click the opening parentheses of the if statement, we get:
Unlike Balance (Alt-B), double-click balancing also works on " " and ' ' pairs. The balancing algorithm uses the syntax coloring plugin to help it determine if a given quote is opening or closing. If syntax coloring is turned off in a document, the double-clicked quote is treated as if it was the string-opening quote.
Balancing < > pairs is usefull when working with C++ templates a lot. You may turn off balancing < > pairs in Application settings if you do not use C++ templates frequently - balancing < > pairs is a little tricky because the < > characters are also used as less and greater than in arithmetic expressions and may confuse the balancing algorithm. This will not happen if the < > balancing is turned off.
By using the Alt-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)