Storing code style in project, in Ultimate 2021.1

Answered

I'm trying to save a code style in our project so that it can be stored in version control, and automatically used by other developers. I've saved the file to `.idea/codeStyles/Project.xml`, and created the file `.idea/codeStyles/codeStyleConfig.xml` with `<option name="USE_PER_PROJECT_SETTINGS" value="true" />`.

As far as I can tell, this ought to result in these code style settings being applied when IntelliJ imports the project, but this doesn't happen.

In case it matters, we are using the Gradle IntelliJ plugin (gradle-idea-ext-plugin), but we aren't configuring code style with that.

0
4 comments

Hello,

To share IDE settings across team members I'd recommend you configure Settings Repository instead of manually changing the .idea directory. Please see https://www.jetbrains.com/help/idea/sharing-your-ide-settings.html#f3f211a9 .

The settings you can sync include IDE themes, keymaps, color schemes, system settings, UI settings, menus and toolbars settings, project view settings, editor settings, code completion settings, parameter name hints, live templates, code styles, and the list of enabled and disabled plugins.

0

Thank you for your suggestion. The documentation suggests using a private repository, but the project in question here has external contributors, and I would like them to be able to configure their IDE the same as employees. Is there any risk with having the settings repository publicly readable?

0
In your case, it is better to configure a read-only settings repository that cannot be overwritten by other developers. See https://www.jetbrains.com/help/idea/sharing-your-ide-settings.html#configure-read-only-repositories .
0

I discovered that I can do what I needed using our `.editorconfig` file. I found all the information I needed in this blog post:

https://blog.jetbrains.com/idea/2019/06/managing-code-style-on-a-directory-level-with-editorconfig/

Particularly in the comments:

When you right-click a folder and select New | EditorConfig File, check the IntelliJ IDEA-specific checkbox in the dialog that opens and, if needed, select the languages used in your project. An .editorconfig file will be generated with all IntelliJ-specific properties listed as comments

1

Please sign in to leave a comment.