File Type Brackets

On the Brackets page in the file type configuration, you can configure bracket matching and automatic breaking and indentation.

Turn on “highlight matching brackets touched by the cursor” to highlight the bracket touched by the cursor and that bracket’s corresponding opening or closing bracket. The cursor touches a bracket when it is positioned immediately to the left or right of the bracket. If the bracket consists of multiple characters, the cursor also touches it if it is positioned between two characters that are part of the bracket. If the cursor touches two brackets at the same time that belong to different pairs, the bracket to the right of the cursor is highlighted. If the corresponding bracket is missing, the bracket touched by the cursor is highlighted by itself, in a different color.

Turn on “highlight innermost pair of brackets containing the cursor” to highlight the pair of opening and closing brackets nearest to the text cursor that surround the text cursor. Brackets surround the cursor if the cursor is positioned to the right of the last character in the opening bracket and to the left of the last character in the closing bracket. If the innermost pair of matching brackets contains an unmatched opening bracket to the left of the cursor or an unmatched closing bracket to the right of the cursor, then that unpaired bracket is highlighted alone in a different color and the innermost pair is not highlighted.

If you turn on both bracket highlighting options, then touching brackets are highlighted if the cursor touches a bracket. The innermost pair containing the cursor is highlighted if the cursor does not touch any brackets.

Exactly which brackets are highlighted and how they are paired up depends on the syntax coloring scheme you selected on the Colors and Syntax page. If the syntax coloring scheme does not define any bracket pairs, EditPad matches up nested pairs of (), [], and {} throughout the file. The provided syntax coloring schemes for programming languages match up these brackets too, depending on how they are used in the programming language. They also match up quotes that are used to delimit strings and characters that delimit multi-line comments.

The syntax coloring schemes for markup formats such as HTML and XML match up entire HTML and XML tags. They can also match up the < and > that delimit the tags. Turn on “highlight brackets within tags” if you want < and > to be paired as brackets when the cursor is inside an HTML or XML tag. Turn it off if you always want the HTML or XML tag to be highlighted along with its corresponding opening or closing tag.

Syntax coloring schemes can specify which closing bracket should be generated when the file contains an unpaired opening bracket. The option “automatically insert matching brackets” is only enabled when the syntax coloring scheme that you selected does so. The option determines the default state of the Edit|Auto Match Brackets menu item. When on, EditPad automatically generates the closing bracket when you enter an opening bracket. See the Edit|Auto Match Brackets topic for more details.

Syntax coloring schemes can also specify that line breaks should be automatically inserted before or after certain text. If the selected scheme does so, you can enable this by ticking “automatically insert line breaks”. You can toggle it for the active file with Options|Auto Break.

Automatic Breaking And Indentation of Braces

A syntax coloring scheme can designate certain text as opening braces or as closing braces for the purposes of automatic breaking and indentation. The schemes for C-style languages included with EditPad do this for braces that surround code blocks. But schemes for other languages such as Delphi that use keywords to delimit blocks also designate the “begin” and “end” keywords as braces. When using such a scheme, you can specify how EditPad should break and indent before those braces.

Schemes for languages such as Visual Basic that have more complicated sets of structural keywords have hard-coded breaking and indentation rules. When using such a syntax coloring scheme, your choices for breaking and indenting around braces are ignored.

EditPad Pro supports the most common indentation styles. Selecting one from the drop-down list updates the eight individual rules for breaking and indenting before and after opening and closing braces. Changing one of the individual rules automatically updates the style drop-down list as well.

The following examples show the results of each of the indentation styles. Invisible line breaks were automatically inserted. Pilcrow signs indicate a line break added by pressing Enter on the keyboard. No indentation spaces were entered by pressing the space bar on the keyboard. No automatically inserted indentation spaces or line breaks were removed by pressing backspace. It is important to resist the urge to backspace excess indentation before typing a closing brace. When you type the closing brace, EditPad automatically outdents the brace by one step.

Java (K&R)

function {
  if {
    true
  } else {
    false
  }
}

If you want the original K&R style with the { of a function block on a separate line, you need one extra press of the Enter key. EditPad’s rules for breaking around braces treat all braces equally. There’s no way to specify to break before certain braces but not before other braces. If that’s what you need then you need to tell EditPad Pro not to break before the brace and press Enter manually before typing the brace when it does need to be on a separate line.

function¶
{
  if {
    true
  } else {
    false
  }
}

C++ (Stroustrup)

function {
  if {
    true
  }
  else {
    false
  }
}

C# (Allman)

function
{
  if
  {
    true
  }
  else
  {
    false
  }
}

Pascal (Allman)

The Pascal variation of the Allman style does not automatically insert line breaks after the “end” keyword so that you can have the semicolon immediately after the “end”. Though it will automatically break after the “begin” keyword, you will often still need to enter the line break after “begin” yourself. EditPad can’t do it as soon as you type “begin” because you may intend to type “beginSomeOperation()” which is not a keyword.

function
begin¶
  if
  begin¶
    true¶
  end¶
  else
  begin¶
    false¶
  end;¶
end;¶

C (Whitesmiths)

function
  {
  if
    {
    true
    }
  else
    {
    false
    }
  }

Lisp

Since EditPad can’t know how many blocks you want to close on any one line, you need to press Enter after typing the last closing brace. EditPad will correctly outdent the next line by as many closing braces you typed before pressing Enter.

function
  {if
    {true}¶
  else
    {false}}¶

Horstmann

function
{ if
  { true
  }
  else
  { false
  }
}

Ratliff

function {
  if {
    true
    }
  else {
    false
    }
  }

GNU

function
  {
    if
      {
        true
      }
    else
      {
        false
      }
  }

Automatic Breaking And Indentation of Markup Tags

A syntax coloring scheme can designate certain text as markup tags for the purposes of automatic breaking and indentation. The HTML and XML schemes included with EditPad do this. The ASP.NET and PHP schemes do this as well, on top of designating braces as such.

EditPad Pro supports two indentation styles for markup tags. It can either break around all tags, or break only around tags that aren't part of mixed content. A tag contains mixed content if its content starts with text rather than with another markup tag. The following is what you get when breaking around all tags. All line breaks and indentation were inserted automatically.

<html>
  <head>
    <title>
      All Tags
    </title>
  </head>
  <body>
    <p>
      Break around
      <i>
        all
      </i>
      markup tags.
    </p>
  </body>
</html>

This is what you get when breaking around tags except those inside mixed content. Again, all line breaks and indentation were inserted automatically.

<html>
  <head>
    <title>Don’t break mixed content</title>
  </head>
  <body>
    <p>Break around tags <i>except</i> within mixed content.</p>
  </body>
</html>