2

I'm using the updated version of the IntelliJ IDEA and am trying to export my code style settings so that they can be used by all developers working on a particular project. I read the tutorials at https://confluence.jetbrains.com/display/IntelliJIDEA/Code+Styles and http://forum.shakacode.com/t/sharing-your-intellij-rubymine-webstorm-codestyle-among-developers/240, which seems fairly simple.

Unfortunately that is not how my 'export settings' pane looks like, and I don't have a line that says 'code styles'. Mine looks like intellij export settings

The closest I can find is the line I highlighted which has CodeStyleSettingsManager in it along with a whole bunch of other stuff. However I tried using that and extracted the .jar file only to find that there was nothing much inside at all.

Does anyone know a way of exporting code styles that works with the latest version of IntelliJ?

Edit: My codeStyleSettings.xml file only contains the following:

<project version="4">
<component name="ProjectCodeStyleSettingsManager">
<option name="PER_PROJECT_SETTINGS">
<value/>
</option>
<option name="USE_PER_PROJECT_SETTINGS" value="true"/>
</component>
</project>
Nicolas Raoul
  • 58,567
  • 58
  • 222
  • 373
misaochan
  • 890
  • 2
  • 8
  • 25

1 Answers1

3

I don't understand, why you don't see Code Style in your list (it appears in my IDEA 14.1.5), but...

(...) export my code style settings so that they can be used by all developers working on a particular project

A better way to share the project code style across all developers is to include it in your VCS repository. Pulling such a commit will apply those code styles automatically. This is the file: project/.idea/codeStyleSettings.xml. If your VCS is set to ignore .idea/, add an exception for this file.

If you don't see this file at all, you're probably using a local formatter and your Project scheme is unchanged. In this case, go to Settings > Editor > Code Style > Scheme: Manage, select your formatter and click Copy to Project.

Update

Code style files only state the difference to the IDEA Default Code style (which is always the same). You can try this yourself: create a new project, go the the Code Style settings, select Project and change only one option. The codeStyleSettings.xml file will be created, and it will contain only this one option. If you could export your code style settings, the output would be exactly the same.

Darek Kay
  • 15,827
  • 7
  • 64
  • 61
  • My codeStyleSettings.xml file only has a few lines, though. Can that really encapsulate all the code style settings? (contents of xml file pasted in opening post) – misaochan Oct 22 '15 at 02:18
  • Thanks Darek! But what if someone wants to import my code style into, say, Eclipse? Will the code style file work for that as well? – misaochan Oct 22 '15 at 12:48
  • AFAIK, there is no way to import IntelliJ code settings into Eclipse. If you want to use the same code styles across different editors/IDEs, try [EditorConfig](http://editorconfig.org/). IntelliJ already supports EditorConfig already, for Eclipse you'll need a plugin. – Darek Kay Oct 22 '15 at 13:51
  • But where can those IDEA Default styles be found? Their documentation says "You can define the code styles that differ from the pre-defined ones" (https://www.jetbrains.com/help/idea/copying-code-style-settings.html). So where are those "pre-defined ones"? – Woodchuck Mar 30 '18 at 17:47
  • @JWoodchuck - Open Settings → Editor → Code Style and change "Scheme" to "Default (IDE)" to see all default values. – Darek Kay Apr 01 '18 at 20:37
  • Thanks, Darek. But the thing is, those can be changed, correct? – Woodchuck Apr 01 '18 at 20:47
  • Further, if I change, say, number of spaces per indent in "Default (IDE)" to 2 and change it in my "project" style also to 2, then when I export my project style settings it still includes that style in the export. I would think it would not include that if the "Default (IDE)" were what it's comparing against (since it supposedly only exports differences). – Woodchuck Apr 02 '18 at 05:17