In the latest versions of IntelliJ IDEA it seems that it isn't possible to import code style files like intellij-java-google-style.xml.
I would like use the Google Java Code Style in this IDE but it seems there isn't a trivial solution.
Go to Settings/Preferences | Editor | Code Style, select your programming language, and open the Wrapping and Braces tab. In the Keep when reformatting section, select the formatting rules which you want to ignore and deselect those which should be applied. Reformat your code ( Ctrl+Alt+L ).
Out of the box, IntelliJ IDEA allows you to import settings in the IntelliJ IDEA code style XML or Eclipse XML Profile format. Press Ctrl+Alt+S to open the IDE settings and select Editor | Code Style. and select Import Scheme. Then select the necessary format.
This problem can be solve installing the google-java-format Plugin.
Open plugins window (CTRL+Shift+A): plugins
Click on browse repositories.
Search for google-java-format
Install the plugin.
Restart the IDE.
Enable the plugin executing the action (Ctrl+Shift+A): Reformat with google-java-format
Additional notes from the google-java-format README
The plugin will be disabled by default. To enable it in the current project, go to File→Settings...→google-java-format Settings (or IntelliJ IDEA→Preferences...→Other Settings→google-java-format Settings on macOS) and check the Enable google-java-format checkbox. (A notification will be presented when you first open a project offering to do this for you.)
To enable it by default in new projects, use File→Other Settings→Default Settings....
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With