IntelliJ auto detect indentation for each file

In recent versions of Intellij there is a Detect and use existing file indents for editing setting for this:

enter image description here


Each project you open in IntelliJ has it's own settings. You will need to set the indent style the first time you open up the project, but it will be saved after that (and can be different for every project you work on). From the IntelliJ help site:

Project settings are stored with each specific project as a set of xml files under the .idea folder. If you specify the default project settings, these settings will be automatically used for each newly created project.

You can edit the indent settings for the project in the Code Style dialog.