Brace matching and brace auto-completion

Brace matching and auto-completion is indispensable for navigating through code. Brace matching allows you to click on an open (or close) brace and highlight the corresponding brace. Brace auto-completion refers to the editor automatically adding a closing brace when you type an opening brace.

Highlight the corresponding brace

To visually locate a brace’s match, simply click on the brace itself and its counterpart is highlighted.

You can change the color of the brace matching highlight in Layout » Themes » Manage themes. Look for the “Brace highlight” setting in the “Editor” tab.

Writing a Macro<br />

Select to the corresponding brace

Often times it’s helpful to select all text between two matching braces. You can do this with the keyboard shortcut Ctrl + B, or the Select to brace command in the Coding tab. This will search forward from the current caret position to find the next brace – whether it’s an opening or closing brace – and then select all text between it and its counterpart.

Writing a Macro<br />

Auto-completing braces

The editor will also automatically complete braces for you. This is helpful when writing code since it can be easy to forget to type a closing brace. This behavior is enabled by default. To see this in action, open a source file and type an opening brace. The editor will close it for you.

Writing a Macro<br />

Configuring brace matching and auto-completion

There are options for configuring brace matching in Advanced » Settings » Editor » Braces / strings. These options are fairly self-explanatory and give you granular control over the brace matching and auto-completing features.

Writing a Macro<br />

5. Restore your settings

Once you’ve backed up your settings, you can restore them to (i.e. transfer them to) your new system with your new installation of UltraEdit very easily. Simply access the “Backup / Restore User Customizations” dialog again under the Advanced menu item, except this time click the Restore tab. Next, click the Browse button to locate the .uec file you saved in step 4 and click Open.

Use the checkboxes to check the customizations from the .uec file you’d like to import. If you’d like to import everything, just check the category checkboxes and all subitems will automatically be checked as well.

Finally, click the Restore button to import your settings and restart UltraEdit. Now you have your previous editing environment on your new system!

Writing a Macro<br />

As mentioned above, you can adjust the color of brace highlighting in the “Manage themes” dialog.

The editor determines what characters are brace characters by the “Open brace strings” and “Close brace strings” defined in the highlighting language’s wordfile. If these aren’t defined in the wordfile, or if no syntax highlighting is applied to the active file, then the following internal defaults are used for open braces:

( [ {

…along with their closing counterparts:

) ] }

If you want to see what strings are used as braces for the active highlighting type, you can open your wordfile by going to Advanced » Settings » Editor display » Syntax highlighting. Make sure the highlighting type is selected in the dropdown and click Open

Writing a Macro<br />

If you wish to modify these, make sure you provide the same number of both open and close brace strings in the wordfile. 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.

Correct example:

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

Incorrect example:

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

Save and close the file when you’re done modifying your brace strings.