We have a Java project in small team, all developers use Intellij IDEA.
I need to setup code style so that
How to achieve it?
My attempts:
.editorconfig
file in project root with some common settings. Since the file is versioned in Git there would be great to have something like .editorconfig-gitignored
file with custom settings (or put .editorconfig
one level down into each subfolder, which is clumsy).editorconfig
settings, it seems to be a solution to define common settings in Idea and custom setting in (newly gitignored) .editorconfig
file. Unfortunately some properties in .editorconfig
are mandatory as well so I feel it would be downgrade at this moment.Finally we decided to treat .editorconfig
file as main source of truth. The file is versioned. The IDEA is set to prefer EditorConfig settings over IDEA XML settings. (Ctrl+Alt+S -> Editor -> Code Style -> General -> Enable EditorConfig support)
The .editorconfig
properties such as indent_style = tab
are obligatory for all team members. On the other hand, properties such as tab_width
intentionally are not in .editorconfig
so IDEA consults its own settings (these are not versioned).
This solution is facilitated by proprietary ij_...
keys in .editorconfig
. With such properties all IDEA config could be exported to .editorconfig
file. When I asked a question 2 years ago, these keys weren't supported or I didn't notice them.