Find Mate

Contents  Previous  Next

 

Menu: Search > Find Mate

 

Default Shortcut Key: Ctrl+]

 

Macro function: FindMate()

 

The Find Mate command locates the mating parenthetical element to the parenthetical element at the text cursor, and moves the text cursor ahead (or back) to that position.  The search begins at the text cursor and will continue all the way to the start or end of the file, as may be needed.

 

If the text cursor is sitting on an opening parenthetical character such as (, [, <, or {­, the cursor will be moved ahead to the corresponding closing mate, with consideration given to nesting.  If the cursor is situated on a closing parenthetical character such as ), ], >, or }, the cursor will be moved back to the corresponding opening mate, again with consideration given to nesting.

 

The Find Mate command also recognizes text strings as parenthetical elements, and many of the most common parenthetical pairs have been pre-defined.  For example: if the cursor is sitting on begin, Find Mate will locate end.  If the cursor is sitting on <i> (the HTML code to begin italics), Find Mate will find </i>.  If the cursor is sitting on while, Find Mate will find endwhile.

 

The Find Mate command can be used to extend an existing text selection to a closing element.  For example, to select a parenthesized block of text, select the opening parenthesis and issue the Find Mate command.  The selection will be extended to include all of the text up to and including the closing parenthesis.

 

The parenthetical pairs recognized by Find Mate can be viewed and/or defined on the Configure | Preferences | Editing options page.  The name of the option is Set mating pairs for Find Mate.

 

 

bm1When editing a file for which syntax highlighting information is available, Find Mate will ignore parenthetical  elements that occur within block comments, end-of-line comments, character constants and quoted strings.  If syntax highlighting is disabled, or unavailable, this feature cannot be performed.

 

bm1Find Mate can also be used to test for unmated parenthetical elements, since a request to find a mate for an unbalanced element will result in a report that the closing mate could not be found.

 

bm1When defining Find Mate pairs for tagged languages such as HTML, remember that commands which include parameters will need different treatment than commands that cannot use parameters. For example, if you were to define 'table' using the definition <table>=</table>, Boxer would not be able to find matches when 'table' was used with parameters, such as <table width="200">.  For this reason, a definition of the form <table=</table> should be used instead, without the closing > character.

 

bm2Find Mate is not able to handle mating pairs whose beginning or ending element is shared by other parenthetical pairs.  For example, the definitions #if=#endif, #ifdef=#endif and #ifndef=#endif all share the same closing element, #endif.  The nesting complexities that could arise from such definitions is beyond the scope of the Find Mate command.