Code Style. Scala
Use this page to configure formatting options for lang files. View the result in the Preview pane on the right.
On this page:
- Tabs and Indents
- Wrapping and Braces
- Blank Lines
- Multi-line strings
- Type Annotations
Tabs and Indents
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 on 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.
Keep When Reformatting
Use the check boxes to configure exceptions that IntelliJ IDEA will make when reformatting the source code. For example, by default, the Line breaks check box is selected. If your code contains lines that are shorter than a standard convention, you can convert them by disabling the Line breaks check box before you reformat the source code.
The wrapping style applies to the various code constructs, specified in the left-hand pane (for example, method call arguments, or assignment statements).
|Wrapping style||From this drop-down list, select the desired wrapping style:
Braces Placement Options
Use this tab to define where and how many blank lines you want IntelliJ IDEA to retain and insert in your code after reformatting. For each type of location, specify the number of blank lines to be inserted. The results are displayed in the Preview pane.
|Keep Maximum Blank Lines||In this area, specify the number of blank lines to be kept after reformatting in the specified locations.|
|Minimum Blank Lines||In the text boxes in this area, specify the number of blank lines to be present in the specified locations.|
Use this tab to configure import settings for your project.
|Class count to use import with '_':||Use this text field, specify the number of classes to be imported from a single package until all statements importing a single class are substituted with a statement importing an entire package.|
|Add import statement in closest block||Select this check box to add your import statement to the closest block instead of the top of your code.|
|Add fully qualified imports||Select this check box to add fully qualified imports.|
|Do not change path during optimize imports for local imports||Select this check box to eliminate changing the local imports into the fully qualified imports.|
|Sort imports lexicographically (for optimize imports)||Use this check box if you want IntelliJ IDEA to sort your imports in lexicographical order.|
|Collect imports with the same prefix into one import||Use this check box if you want IntelliJ IDEA to insert all imports with the same prefix into one.|
|Import members using '_'||If you select this check box then IntelliJ IDEA imports all members included in the object. If the check box is cleared, IntelliJ IDEA imports only a specific member such as method or a field from the object.|
|Use the shortest path, when trying to import reference with already imported name||Select this check box to let IntelliJ IDEA find the shortest available path when you import the reference with already imported name using code completion.|
|Classes to use only with prefix||This area lets you view the list of classes with prefixes. You can add a pattern to use appropriate classes only with prefix or you can remove a class from the list.|
|Import Layout||this area lets you view the layout of the import statements, add or remove blank lines between them,and add or remove package names. You can also move the rows in the layout up or down .|
|Multi-line support||Use this list to choose the support for the multi-line strings.
You can choose from the following options:
|Margin char||Use this field to enter a character to use in the |
|Margin char indent||Use this field to increase or decrease the indent for the Margin char.|
|Opening quotes on new line||Select this check box to place the opening quotes on the new line.|
|Keep opening quotes||Select this check box to keep the opening quotes on the same line overriding the Opening quotes on new line option.|
|Strip/Insert margin on copy/paste||Select this check box to remove the margin character when you copy/paste content of the margin. When this check box is cleared, the margin character is also copied and pasted.|
Use these settings for the code inspections.
|Instance Type Annotations||Use this area to configure settings for Instance Type Annotations.|
|Local type Annotations||Use this area to configure settings for Local Type Annotations.|
|Special Cases||Use this area to configure setting for special cases in type annotations.|
This tab lets you define a set of rules that rearranges your code according to your preferences.
|Grouping Rules||Use this area to set the grouping rules.
|Matching rules||Use this area to define elements order as a list of rules, where every rule has a set of matches such as
modifier or type.
|Empty rule||Use this window to create a new matching rule or edit an existing one.
You can select from the following filters:
|This icon appears when you select Order by Name in Order option. The icon indicates that the items in this rule are alphabetized.|
Use this tab to configure syntax when you use certain symbols in the code.
|Enforce procedure syntax for methods with Unit return type||Select this check box to show the explicit syntax for methods with Unit return type.|
|Replace '=>' with unicode symbol||Select this check box to change '=>' symbol to one in Unicode.|
|Replace '->' with unicode symbol||Select this check box to change '->' symbol to one in Unicode.|
|Replace '<-' in "for" generator with unicode symbol||Select this check box to change '<-' symbol to one in Unicode.|
|Kind Projector: Replace 'Lambda' with unicode symbol||Select this check box to change 'Lambda' symbol to one in Unicode.|