![]() |
| Add, edit or select code style |
But if you needs to create a new code formatting style, same way you can first go to File > Settings>Code Style > Manage and select existing code formatter style. Afterr words you can do "Save As"where it saves new copy from the original which you can do the changes.
So what are the available code formatting settings in Intellij IDEA. As the most popular Java IDE, it has several cool properties that you can select to make your own code style formatter.
I will give a brief idea on what each tab do. You can find more details in [1]. I will closely look at Java language specific code formatting.
There is a General tab which contains the general settings for the all the supported languages as in below image. Where you specify maximum length for the line and etc.
![]() |
| General Tab |
General tab contains below properties. For more details look at [1].
- Right margin, Formatter on/off tags
- Indentation
- Indent size
- Usage of ‘Tab’ character
- Usage of Tab only for leading indentation (Smart Tabs)
- Indent ‘case’ branches from ‘switch’
- Indent class members
- Keep comment at first column
- Before/after comma (as set for Eclipse method declaration parameters)
- After comma in type arguments
- Within array initializer braces
- Within brackets (in array reference)
- Within parentheses of: annotation, ‘for’, ‘if’, ‘catch’ ’while’, ’switch’, method, empty method, parenthesized expression, method call, type cast, ‘synchronized’
- Before parentheses of: ‘try’, ‘for’, ’while’, ‘switch’, method, ’if’, ‘catch’, method, method call, ‘synchronized’.
- After type cast
- Around unary, assignment operators (if it’s set for ‘before’ and ‘after’ in Eclipse).
- Before opening brace of: array initializer, ‘switch’
- Before ‘?’ in conditional expression
- Space before/after ‘:’ in conditional expression
- Space around binary operators (a single Eclipse setting is mapped to multiple IntelliJ IDEA’s settings)
![]() |
| Spaces tab |
Blank lines tab contains the rules for where to insert blank lines between different sections such as imports licence headers and etc. Below are the several properties. For more details look at [1].
Wrapping and Braces tab contains the rules for where we needs to wrap lines for example, we may perform line wrap if single line exceed maximum line length. Below are the several properties. For more details look at [1].
- Around fields and methods
- Before/after package
- Before/after imports
- Before method body
- Keep blank lines in code (number of empty lines to preserve)
![]() |
| Blank Lines |
- New line before: closing brace in array initializer, ‘else’ in ‘if’ statement, ‘finally’ and ‘catch’ in ‘try’ statement, binary operator (if wrapped)
- New line after: opening brace in array initializer
- Special ‘else if’ treatment (compact ‘else if’)
- Keep simple blocks in one line
- Keep control statements in one line
- Alignment of: array initializer expressions, arguments in method declarations and calls, field declarations, extends list, assignments, binary expressions, ‘throws’ clause, resources in ‘try’.
- Brace style for: code blocks, methods and classes
![]() |
| Wrapping and Braces |
- Enable JavaDoc formatting
- Blank lines in JavaD
![]() |
| Java Doc |
Imports tab contains rules on how we format imports in the class. Sometimes you will notice that, Intellij IDEA perform wild card imports. It can be overcome with this tab settings . For more details look at [1].
![]() |
| Imports |
![]() |
| Arrangement |
After you select the appropriate rules, click apply. Then you can apply the formatting rules and you can take out the current configuration from above mentioned configuration location.
[1] - https://www.jetbrains.com/idea/help/code-style-java.html
[2] - http://blog.jetbrains.com/idea/2014/01/intellij-idea-13-importing-code-formatter-settings-from-eclipse/







