Format

The Format preferences panel is opened from menu OptionsPreferences+Editor+Format

 

Figure 22.11. The Format preferences panel

The Format preferences panel

Detect indent on open

The editor tries to detect the indent settings of the opened XML document. In this way you can correctly format (pretty-print) files that were created with different settings, without changing your options. More than that you can activate the advanced option for detecting the maximum line width to be used for formatting and hard wrap. These features were designed to minimize the differences created by the pretty print operation when working with a versioning system, like CVS for example.

Indent with tabs

When checked enables 'Indent with tabs' to set the indent to a tab unit. When unchecked, 'Indent with tabs' is disabled and the indent will measure as many spaces as defined by the 'Indent size' option.

Indent size

Sets the number of spaces or the tab size that will equal a single indent. The Indent can be spaces or a tab, select the preference using the Indent With Tabs option. If set to 4 one tab will equal 4 white spaces or 1 tab with size of 4 characters depending on which option was set in the Indent With Tabs option.

Hard line wrap

This feature saves time when writing a reach text XML document. You can set a limit for the length of the lines in your document. When this limit is exceeded the editor will insert a new line before the word that breaks the limit, and indent the next line. This will minimize the need of reformatting the document.

Indent on Enter

If checked, it indents the new line introduced when pressing Enter.

Enable Smart Enter

If checked, it inserts a new indented line between start and end tag.

Detect line width on open

If checked, it detects the line width automatically when the document is opened.

Format and indent the document on open

When checked, the Format and indent the document on open operation will format and indent the document before opening it in the editor panel.

Line width - Format and Indent

Defines the point at which the "Format and Indent" (Pretty-Print) function will perform hard line wrapping. So if set to 100 Pretty-Print will wrap lines at the 100th space inclusive of white spaces, tags and elements.

Clear undo buffer before Format and Indent

If checked, the undo buffer is cleared. The undo action can now only undo the Format and Indent action

 XML

The XML Format preferences panel is opened from menu OptionsPreferences+Editor+Format+XML

 

Figure 22.12. The XML format preferences panel

The XML format preferences panel

Preserve empty lines

When checked the Format and Indent operation will preserve all empty lines found in the document on which the pretty-print operation os applied.

Preserve text as it is

If checked, the "Format and Indent" (Pretty-Print) function will preserve text nodes as they are without removing or adding any whitespace.

Preserve line breaks in attributes

If checked, the "Format and Indent" (Pretty-Print) function will preserve the line breaks found in attributes. When this option is checked, Break long lines option will be disabled.

Break long attributes

If checked, the "Format and Indent" (Pretty-Print) function will break long attributes.

Expand empty elements

When checked the Format and Indent operation will output empty elements with a separate closing tag, ex. <a atr1="v1"></a>. When not checked the same operation will represent an empty element in a more compact form: <a atr1="v1"/>

Sort attributes

When checked the Format and Indent operation will sort the attributes of an element alphabetically. When not checked the same operation will leave them in the same order as before applying the operation.

Add space before slash in empty elements

When checked the Format and Indent operation will add a space before the closing slash of an empty element, for instance an empty br will appear as <br />.

Break line before attribute's name

If checked, the "Format and Indent" (Pretty-Print) function will break the line before the attribute's name.

Preserve space elements (XPath)

This list contains simplified XPath expressions for the names of the elements for which the contained white spaces like blanks, tabs and newlines are preserved by the Format and Indent operation exactly as before applying the operation. The allowed XPath expressions are of one of the form:

  • author

  • //listing

  • /chapter/abstract/title

  • //xs:documentation

The namespace prefixes like xs in the previous example are treated as part of the element name without taking into account its binding to a namespace.

Strip space elements (XPath)

This list contains the names of the elements for which contiguous white spaces like blanks, tabs and newlines are merged by the Format and Indent operation into one blank.

Indent (when typing) in preserve space elements

If checked, automatic tags indentation while editing will take place for all elements including the ones that are excluded from Pretty Print (default behaviour). When unchecked, indentation while editing will not take place in elements that have the 'xml:space' attribute set on 'preserve' or are in the list of Preserve Space Elements.

Indent on paste

Indent paste text corresponding to the indent settings set by the user. This is useful for keeping the indent style of text copied from other document.

Locks/Unlocks the XML tags

The default state of the opened editors. For more information see the Locking and unlocking XML markup section.

 Whitespaces

This panel displays the special whitespace characters of Unicode. Any character that is checked in this panel is considered whitespace that can be normalized in an XML document. The whitespaces are normalized when the action Format and Indent is applied or when you switch from Text mode to Author mode or from Author mode to Text mode.

The characters with the codes 9, 10, 13 and 32 are always in the group of whitespace characters that must be normalized so they are always enabled in this panel.

 

Figure 22.13. The Whitespaces preferences panel

The Whitespaces preferences panel