IntelliJ IDEA 14.1.0 Help

Code Style and Formatting

Code style defines how code looks in terms of indents, spacing, wrapping, blank lines treatment, statements order, etc.

In this section:

Reformat code

IntelliJ IDEA automatically applies code style you've configured as you edit, and in most cases you don't need to call Reformat Code action explicitly. However, you can do so by pressing Alt + Ctrl + L (Alt + Cmd + L for Mac.) for a directory or a module or by pressing Alt + Ctrl + Shift + L to reformat current file or selected piece of code.

For more details on reformatting, see Reformatting Source Code.

Auto-indent lines

Another useful action is Auto-Indent Lines, which helps you to fix line indentation. This action sometimes is a better option than Reformat Code, because it does not require you to select anything. Just press Alt + Ctrl + I (Alt + Cmd + I for Mac), and it will quickly fix indents for the current line.

Refer to the section Changing Indentation.


IntelliJ IDEA lets you configure code style settings for each of the supported languages either at the project or IDE level in the Code Style section of the Settings dialog.

When you choose Project scheme in settings, you can share your code style with other team members via version control.

Refer to the section Configuring code style.

Tab character

Last, but not least of the settings worth your attention is Use tab character. By default, this setting is off and IntelliJ IDEA uses regular spaces for indents instead of tabs. If you have files with lots of indents, you may want to optimize their size by selecting this option.

Last modified: 14 July 2015