IntelliJ IDEA 2024.1 Help

Code Style. XML

Use this page to configure formatting options for XML files. When you change these settings, the Preview pane shows how this will affect your code.

Tabs and Indents

Use tab character

  • If this checkbox is selected, tab characters are used:

    • On pressing the Tab key

    • For indentation

    • For reformatting code

  • If the checkbox is cleared, IntelliJ IDEA uses spaces instead of tabs.

Smart tabs

An indentation consists of two parts. One part results from nesting code blocks, and the other part is determined by alignment.

  • If this checkbox is selected, the part that results from nesting contains both tabs and spaces (if necessary), while the part defined by alignment consists only of spaces.

  • If this checkbox is cleared, only tabs are used. This means that after reformatting a group of spaces that fits the specified tab size is automatically replaced with a tab, which may result in breaking fine alignment.

Tab size

In this field, specify the number of spaces that fits in a tab.

Indent

In this field, specify the number of spaces to be inserted for each indent level.

Continuation indent

In this field, specify the number of spaces to be inserted between the elements of an array, in expressions, method declarations, and method calls.

Keep indents on empty lines

If this checkbox is selected, IntelliJ IDEA retains indents on empty lines as if they contained some code. If the checkbox is cleared, IntelliJ IDEA deletes the tab characters and spaces on empty lines.

Other

Item

Description

Right Margin

Use these settings to specify a margin space required on the right side of an element. If you select Default option then a value of the right margin from the global settings will be used.

Wrap on typing

Use these settings to specify how the edited text is fitted in the specified Right margin. You can select one the following options:

  • Default - in this case IntelliJ IDEA uses the Wrap on typing option that is specified in the global settings.

  • Yes - in this case the value in the specified right margin is used.

  • No - in this case this option is switched off, and a line can exceed the number that is specified in the right margin.

Keep line breaks

Select this checkbox to have IntelliJ IDEA honor line breaks when reviewing XML files in the editor.

Keep line breaks in text

Select this checkbox to have IntelliJ IDEA honor line breaks in attributes (for example, lengthy descriptions) when reviewing XML files in the editor.

Keep blank lines

In this field, specify the minimum number of sequential blank lines to be retained after reformatting.

Wrap attributes

Use this list to determine how attribute lines should be wrapped. The available options are:

  • Do not wrap - if this option is selected, no special wrapping style is applied to the code.

  • Wrap if long - select this option to have lines going beyond the right margin wrapped with proper indentation.

  • Chop down if long - select this option to have elements in lists that go beyond the right margin wrapped to give one element per line with proper indentation.

  • Wrap always - select this option to have all elements in lists wrapped to give one element per line with proper indentation.

Wrap text

Select this checkbox to have long lines wrapped according to the code style settings.

Align attributes

Select this checkbox to have attributes in sequential lines aligned.

Keep white spaces

When this checkbox is selected, the editor preserves all whitespaces within tags. The same refers also to the indents, and line breaks.

Spaces

In this area, define the usage of spaces for attributes and tag names.

  • Around "=" in attribute: select this checkbox to have spaces added around the "=" symbol in attributes.

  • After tag name: select this checkbox to have spaces added after tag names.

  • In empty tag: select this checkbox to have spaces added in empty tags.

CDATA

In this area, define the usage of whitespaces around and inside CDATA sections in MXML files:

  • Whitespaces around: from the list, choose how whitespaces around CDATA will be treated.

    • Preserve: all whitespaces will be left intact after reformatting.

    • Remove (keep with tags): all whitespaces around CDATA will be removed, and tags will be kept on the same lines.

    • New lines: new lines will be added before and after CDATA.

  • Keep whitespaces inside: If this checkbox is selected, whitespaces will be preserved after CDATA[ and before ]].

Arrangement

Use the Matching rules area to define the list of rules and their order.

The Add Rule button

Add a new rule.

The Remove Rule button

Remove the selected rules from the list.

The Edit Rule button

Edit the selected rule.

The Move Up button and The Move Down button

Change the order of the rules in the list.

Each rule can match the following:

  • Type: match only tags or attributes. Click a type twice to disable the filter and match both.

  • Name: match the entire name of the element. This filter supports regular expressions and uses the standard syntax.

  • Namespace: match the namespace attribute.

  • Order: Select how to order multiple elements that match the same rule. For example, if there are multiple attributes with the same name, select keep order to arrange them in the same order, or select order by name to sort the matching attributes alphabetically by their value. Rules with alphabetical sorting are designated by the Sort Alphabetically icon.

Use the Force rearrange list to select the default rearrangement behavior when you reformat the code. This defines the default state of the Rearrange entries checkbox in the Reformat Code dialog.

  • Use current mode (toggled in the Reformat Code dialog): The Rearrange entries checkbox is enabled by default, but you can change it.

  • Always: The Rearrange entries checkbox is enabled by default, and you cannot change it.

  • Never: The Rearrange entries checkbox is disabled by default, and you cannot change it.

Set from

The link appears in the upper-right corner of the page, when applicable. Click this link and choose the language to be used as the base for the current language code style.

To return to the initial set of code style settings and discard the changes, click Reset.

Last modified: 26 May 2024