Beacze
Beacze

Reputation: 534

Eclipse Code Formatter indents with double amount of spaces - Intellij IDE

I have configured Eclipse Code Formatter to indent with 4 spaces but after run code formatter I'm getting double amount of spaces.

enter image description here

When I indent with standard settings of Intellij I'm getting correct amount of spaces.

Checkstyle rule:

<module name="Indentation">
    <property name="basicOffset" value="4"/>
    <property name="braceAdjustment" value="0"/>
    <property name="caseIndent" value="4"/>
    <property name="throwsIndent" value="4"/>
    <property name="lineWrappingIndentation" value="4"/>
    <property name="arrayInitIndent" value="4"/>
</module>

Eclipse Code Formatter:

<setting id="org.eclipse.jdt.core.formatter.tabulation.char" value="space"/>
<setting id="org.eclipse.jdt.core.formatter.tabulation.size" value="4"/>
<setting id="org.eclipse.jdt.core.formatter.indentation.size" value="4"/>
<setting id="org.eclipse.jdt.core.formatter.continuation_indentation" value="4"/>

Settings of IDE: enter image description here

What can cause double size of indentation after run the code formatter?

Upvotes: 4

Views: 2351

Answers (1)

Sebastian Forza
Sebastian Forza

Reputation: 169

I experienced the same behavior with eclipse code formatter for "continuation indents", the amount of spaces was doubled from 4 to 8. My eclipse code formatter file had these lines:

<setting id="org.eclipse.jdt.core.formatter.tabulation.char" value="space"/>
<setting id="org.eclipse.jdt.core.formatter.tabulation.size" value="4"/>
<setting id="org.eclipse.jdt.core.formatter.indentation.size" value="4"/>
<setting id="org.eclipse.jdt.core.formatter.continuation_indentation" value="2"/>

The last line with "continuation_indentation" was set to to 2 which led me to the conclusion this could be a factor of 2 (4 x 2 = 8, right 🙂). I changed the value to "1" and it worked. Maybe that helps.

Btw. my settings in Intellij look the same like yours enter image description here

Upvotes: 4

Related Questions