How to stop IntelliJ from switching back to project code style?

Viewed 611

My IntelliJ (Community 2019.3.4) keeps switching the active code style from Default to Project. I'm not 100% sure, but I think it's triggered by branch switches and/or other Git operations. I'm doing those outside IntelliJ, not using its built-in Git interface.

So, why is IntelliJ constantly overriding the code style, and how do I make it stop?

1 Answers

The Code Style settings are stored under $projectRoot$/.idea/codeStyles.

enter image description here

To use the standard Project.xml (Project) configuration, the codeStyleConfig.xml file should contain:

<component name="ProjectCodeStyleConfiguration">
  <state>
    <option name="USE_PER_PROJECT_SETTINGS" value="true" />
  </state>
</component>

enter image description here


When at IDE - Default, codeStyleConfig.xml should contain:

<component name="ProjectCodeStyleConfiguration">
  <state>
    <option name="PREFERRED_PROJECT_CODE_STYLE" value="Default" />
  </state>
</component>
Related