Tuesday, March 16, 2010

Bookmark and Share

Recently I received an IntelliJ IDEA code style settings file for Hibernate Validator, the reference implementation of JSR 303 ("Bean Validation"), to which I'm contributing.

I wanted to import it into IntelliJ in order to format any code changes I make in the project's standard style. But as it turned out, there is no functionality within the IDE for importing code style settings. Instead one has to do the following:

  • Copy the settings XML file to INTELLIJ_SETTINGS_DIR/config/codestyles (where INTELLIJ_SETTINGS_DIR is the folder containing your IntelliJ settings; typically it is situated within your home directory, the name depends on your version of IntelliJ; in my case the complete path is "~/.IdeaIC90/config/codestyles")
  • Start IntelliJ
  • Go to "File" - "Settings" - "Code Style", select "Use global settings" and choose the previously imported style from the drop-down box
  • Optionally apply the style to one project only by clicking on "Copy to Project" and selecting "Use per project settings" afterwards


Unknown said...

In Idea 10, use File -> Export/Import settings.
Which will allow you to select/deselect from many categories of settings (including code style).

Unknown said...

Eric, that's great to know. That option wasn't available when I wrote this post. So things got definitely easier since then.

Unknown said...

For those interested: In IntelliJ 11 on Mac, the settings directory is ~/Library/Preferences/IntelliJIdea11/codestyles/.

Hyman said...

This is great!

Magdalena said...

Actually the post is useful also now (with IntelliJ IDEA 14) because when I tried File -> Import settings I got
"Error reading file '/home/magdalena/Downloads/hibernate-style-steve-2.xml'.
There was error in opening zip file"
But coping to codestyles folder worked.

Anonymous said...

With IntelliJ 14 (for OSX), I had to paste to the following folder: ~/Library/Preferences/IdealC14/codestyles/. Hope someone finds this useful. @Magdalena, I had the same error when trying to use the ide to import settings.

GG. said...

This looks to be the perfect
London dominatrix