IntelliJ IDEA 14.0.0 Web Help

Code Style. SQL

File | Settings | Editor | Code Style | SQL


Use this page to configure formatting options for SQL files. View the result in the Preview pane on the right.

On this page:

General

Use this tab to specify certain formatting behaviors in your code. The results are displayed in the Preview pane.

Item Description
Word Case In this node, specify whether the keywords, identifiers, or quoted identifiers case should change automatically. Click the right-hand column, and check the desired behavior on the menu to turn it on.

The possible options are:

  • To upper: the elements are automatically converted to the upper case.
  • To lower: The elements are automatically converted to lower case.
  • Do not change: The case of elements is left as is.
Identifier quotations Click the right-hand column, and check the desired behavior on the menu to turn it on.

The possible options are:

  • Quote: the identifiers are automatically quoted.
  • Unquote: The identifiers are automatically unquoted.
  • Do not change: The identifiers are left as is.
New line before/after Use these nodes to define how many blank lines you want IntelliJ IDEA to retain and insert in your code after reformatting. For each type of SQL element, select of clear the check box to the right. The results are highlighted in the Preview pane.
New line around semicolon Use this check box to manage line delimiters around a semicolon.
Alignment Select the check boxes next to the desired elements of source code to have them automatically aligned.

Tabs and Indents

Item Description
Use tab character
  • If this check box is selected, tab characters are used:
    • On pressing the Tab key
    • For indentation
    • For code reformatting
  • When the check box is cleared, IntelliJ IDEA uses spaces instead of tabs.
Smart tabs
  • If this check box is selected, IntelliJ IDEA inserts tabs for indentation and reformatting, but fine alignment to a necessary column is done only via spaces without replacing them with tabs. This is done in order to preserve visual representation of the source code, when the Tab Size is changed.
  • If this check box is cleared, only tabs are used. This means that a group of spaces that fits the specified tab size is automatically replaced with a tab, which may result in breaking fine alignment.

The Smart Tabs check box is available if the Use Tab Character check box is selected.

Tab size In this text box, specify the number of spaces included in a tab.
Indent In this text box, specify the number of spaces (or tabs if the Use Tab Character check box is selected) to be inserted for each indent level.
Continuation indent In this text box, specify the number of spaces (or tabs if the Use Tab Character check box is selected) to be inserted at the next line in case of a construct break.
Keep indents on empty lines If this check box is selected, then IntelliJ IDEA will keep indents on the empty lines as if they have contained some code.
If this check box is not selected, IntelliJ IDEA will delete the tabulation characters.
Detect and use existing file indents for editing Use this check box to detect code style settings in the currently edited file on the fly. In this case, when you open a file in the editor, indentation that was used in that file is preserved automatically. For example, if tabs were used for the indentation then in copy, paste or enter actions, tabs are used. Also, note that if you use the Reformat Code command then IntelliJ IDEA applies default code style settings and uses them in the editor.

Spaces

Use this tab to specify where you want spaces in your code. To have IntelliJ IDEA automatically insert a space at a location, select the check box next to this location in the list. The results are displayed in the Preview pane.

Wrapping and Braces

In this tab, customize the code style options, which IntelliJ IDEA will apply when reformatting the source code. The left-hand pane contains the list of exceptions (Keep when reformatting), and placement and alignment options for the various code constructs (lists, statements, operations, annotations, etc.). The right-hand pane shows preview.

Alignment takes precedence over indentation options.

Item Description
Keep When Reformatting Use the check boxes in this node to configure exceptions that IntelliJ IDEA will make when reformatting the source code. For example, by default, the Line brakes check box is selected. If your code contains lines that are shorter than a standard convention, you can convert them by disabling the Line brakes check box before you reformat the source code.
Wrap inside Use this node to define wrapping style for the lengthy elements.
You can use different wrapping style options that are available from the drop-down list in the left-hand pane.
Values expression Use this option to define wrapping style for values expressions. You can use different wrapping style options that are available from the drop-down list in the left-hand pane.
Wrapping Style Options The wrapping style applies to the various code constructs, specified in the left-hand pane (for example, expressions, or assignment statements).
From the drop-down list, select the desired wrapping style:
  • Do not wrap - when this option is selected, no special wrapping style is applied.
  • 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 so that there is one element per line with proper indentation.
  • Wrap always - select this option to have all elements in lists wrapped so that there is one element per line with proper indentation.

Blank lines

Use this tab to insert blank lines into your code.

Item Description
Keep Maximum Blank Lines Use this area to specify blank lines in your code.
Use In code field to enter the number of lines you want to insert. The default number is 2.

Set From

Click this link to reveal the list of languages to be used as the base for the current language code style. So doing, only the settings that are applicable to the current language are taken. All the other settings are not affected.

This link appears in the upper-right corner of the language-specific code style page, when applicable.

Click Reset to discard changes and return to the initial set of code style settings.

See Also

Last modified: 12 November 2014
comments powered by Disqus