Misplaced and unmatched brackets are one of the most common syntax errors encountered when writing code. jEdit has several features to make brackets easier to deal with.
Positioning the caret immediately after a bracket will highlight the corresponding closing or opening bracket (assuming it is visible) and draw a scope indicator in the gutter. If the highlighted bracket is not visible, the text of the matching line will be shown in the status bar. If the matching line consists of only whitespace and the bracket itself, the line before is shown instead. This feature is very useful for code with brackets indented like so:
public void someMethod() { if(isOK) { doSomething(); } } |
Invoking Edit>Source Code>Go to Matching Bracket (shortcut: Control-]), or clicking the scope indicator in the gutter moves the caret to the highlighted bracket.
Edit>Source Code>Select Code Block (shortcut: Control-[) selects all text between the two brackets surrounding the caret.
Holding down Control while clicking the scope indicator or a bracket in the text area will select all text between the two matching brackets.
Edit>Source Code>Go to Previous Bracket (shortcut: Control-E [) moves the caret to the previous opening bracket.
Edit>Source Code>Go to Next Bracket (shortcut: Control-E ]) moves the caret to the next closing bracket.
Bracket highlighting for the text area and gutter, respectively, can be disabled in the Text Area and Gutter panes of the Utilities>Global Options dialog box; see the section called "The Global Options Dialog Box".
jEdit's bracket matching algorithm only checks syntax tokens with the same type as the original bracket for matches. So brackets inside string literals and comments will not cause problems, as they will be skipped.