Code style and formatting
The code formatting standard determines the style of indentation, the use of spaces when formatting expressions, the method of placing parentheses delimiting logical blocks, empty lines, the order of operators, etc.-
Code Formatting
IntelliJ IDEA automatically applies the code style you configure when editing, and in most cases you don't need to call Reformat Code explicitly. However, you can do this at any time for an entire file, just a selected piece of code, or even an entire directory by simply pressing Alt + Ctrl + L ( Alt + Cmd + L for Mac.)
If you want to apply Reformat Code to all files in a directory, use the same button on the project toolbar.
-
Automatic line alignment
Another useful feature is Auto-Indent Lines , which helps you fix line indentation. This action is sometimes a better option than Reformat Code because it doesn't require you to select anything. Just press Alt + Ctrl + I (Alt + Cmd + I for Mac) and the current line will be indented quickly.
-
Settings
IntelliJ IDEA allows you to configure code style settings for each of the supported languages, either for a project or for the development environment as a whole using Settings → Code Style
Style sheets for a project can be distributed to other members of your development team using version control.
-
Tab character
The last but not least important setting worth your attention is Use tab character. By default, this setting is disabled, and IntelliJ IDEA uses regular spaces to line lines instead of tab characters. If your files use too many spaces for code alignment, you can optimize their size by enabling this setting (4 spaces will be replaced by 1 tab character).
GO TO FULL VERSION