IDM PowerTips

Brace Matching

Brace matching is an often-used feature; it is indispensable for navigating through your code. Brace matching simply allows you to position your cursor next to an open (or close) brace and highlight the corresponding brace.

How does brace matching work?

Highlight corresponding brace

If you position your cursor next to an open brace, UltraEdit/UEStudio will highlight the corresponding brace.

Brace matching

Match brace

The match brace (CTRL+B command) searches forward in the file from the cursor position to find a corresponding open/close brace.

If UltraEdit/UEStudio finds an open brace first, the search continues forward until the corresponding close brace is found. If the first brace found is a close brace, the search is performed in the reverse until the matching open brace is found.

When the matching brace is found, all the text between and including the two braces is highlighted.

Brace matching

Configuring brace matching

You can enable brace matching in Advanced : Configuration : Editor Display : Brace Matching; make sure the "Enable auto-brace matching" is checked.

Brace matching

You can configure the colors for brace matching in View : Set Colors. Select your desired foreground and background color for the "Brace Highlight" color swatch.

Brace matching

Advanced brace matching configuration

UltraEdit has defaults for Open and Close Brace Strings for many languages. If no strings are specified in the wordfile, the defaults are used.

The default open braces are '(', '[', or '{' and corresponding close braces are ')', ']' and '}'. Of course, you can also define which braces to use.

The open/close braces are defined in the wordfile on a per language basis. You can find the wordfile in Advanced : Configuration : Editor Display : Syntax Highlighting.

To edit the brace matching strings, select the appropriate language and click the Open button.

Brace matching

The open/close brace strings are defined as follows:

Correct example:

/Open Brace Strings = "{" "(" "["
/Close Brace Strings = "}" ")" "]"

Note: In order for your braces to match properly, the closing brace definition in the wordfile MUST be in the same position as the opening brace definition, in the list of brace strings.

Incorrect example:

/Open Brace Strings = "{" "(" "["
/Close Brace Strings = "}"

Save and close the file when you have finished modifying your brace strings.