Edit|Insert Matching Bracket

(available in EditPad Pro only)

The Insert Matching Bracket command is only available when bracket matching is enabled in the syntax coloring section of the file type configuration for the active file's file type. The syntax coloring scheme determines exactly which brackets are matched. See that section in this help file to learn how bracket matching works in EditPad Pro.

Just like the syntax coloring scheme determines which brackets are matched, it also determines what is inserted by the Insert Matching Bracket command. When an unclosed opening bracket is highlighted, the corresponding closing bracket is inserted. When an unmatched closing bracket is highlighted, the corresponding opening bracket is inserted. The HTML and XML schemes insert matching opening and closing tags.

The Insert Matching Bracket command is intended to be used while typing with minimal cursor movement. If you wanted to type "this <b>bold</b> word" into an HTML file, you would first type "this <b>bold", then use Edit|Insert Matching Bracket, and then type " word". When you use Edit|Insert Matching Bracket, the cursor is automatically placed after the inserted tag.

Do not use Insert Matching Bracket immediately after typing "this <b>". Though it may seem neat to close the bold tag immediately, before typing its contents, this requires unnecessary cursor movement. You'd end up with the cursor after "this <b></b>" requiring you to move the cursor back over the "</b>" tag, then type "bold", then move the cursor forward over "</b>" and then type " word". Since EditPad Pro automatically highlights the "<b>" tag as long as it is unclosed, there is no need to close it immediately. Simply leave it unclosed until you have typed in everything you want between the tag, and then use Edit|Insert Matching Bracket.

If you use Insert Matching Bracket when an unmatched closing bracket is highlighted, it inserts the matching opening bracket. The cursor is then placed to the left of the bracket that was inserted. This way you can easily use Edit|Insert Matching Bracket repeatedly to insert multiple opening brackets. E.g. if you type "unclosed)}]" into a C++ file, then put the cursor before "unclosed", and then use Edit|Insert Matching Bracket three times, you'll get "[{(unclosed)}]".

The Insert Matching Bracket command can match up an unmatched bracket even when matching brackets are highlighted. In the C statement if (a == b) && (c == d)) the last ) is unmatched. If you put the cursor before the first (, EditPad Pro will highlight it as being matched with the ) after b. This clearly shows that the if statement isn't properly enclosed in parentheses. If you use Edit|Insert Matching Bracket with the cursor at this position, EditPad Pro looks for the nearest unmatched bracket. In this case that is the final ) in the statement. EditPad Pro inserts (, correctly completing if ((a == b) && (c == d)).

See also

Edit Menu
Go|Go to Matching Bracket
Block|Between Matching Brackets
File Types|Colors and Syntax