This has been bothering me for a while, but I can't seem to figure out how to change this formatting. Let's take a case class as an example:
I prefer two tabs after a line-continuation; however, IntelliJ seems to force this style:
This behavior seems to be controlled by Preferences -> Editor -> Code Style -> Scala -> Other -> Alternate indentation for constructor args and parameter declarations
, which specifies a minimum of 0 spaces, and that simply brings the arg list inline with the opening parentheses. This isn't a big deal by itself, but whenever I copy/paste blocks of code, it reformats everything and I have to go back and shift-tab ad nauseam. Is there a style field that I'm missing somewhere?
If you need to adjust indentation settings, in the Settings/Preferences dialog ( Ctrl+Alt+S ), go to Editor | Code Style. On the appropriate language page, on the Tabs and Indents tab, specify the appropriate indents options and click OK.
Press Ctrl+Alt+S to open the IDE settings and select Editor | Code Style. Select the Detect and use existing file indents for editing checkbox.
IDEA has a “smart tabs” option that you can turn on: 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. This is done in order to preserve visual representation of the source code, when the Tab Size is changed.
There's an Intellij only solution:
Under Wrapping and Braces
, disable Method declaration parameters > Use normal indent for parameters
.
Then, under Other
, enable Alternate indentation for constructor args and parameter declarations
and set to the number of spaces you want to indent from the declaration level (in your case 4).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With