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.
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.
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 Update: in the newer version of the plugin select Reformat since the plugin overrides / enhances the functionality of the standard "Reformat" command.
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....
As mentioned Here, Download the intellij-java-google-style.xml file from the This Link.
Then in Intellij, go Under Settings -> Editor -> Code Style. there in Scheme settings (settings icon on right side) -> import schemes-> intellij idea code style xml. Select the xml downloaded in first step. then in Scheme dropdown select the GoogleStyle IDE (newly added style). Click on apply and close.
After doing above steps mentioned by Lorenzo, for applying the setting in the current project :- Intellij>Preferences>google-java-format setting and enable it in intellij; as it wont be enabled by default after doing restart as well.
If you want to have this setting for the projects which will you create after installing this plugin , then Go to File >Other Settings> Default Settings> google-java-format-setting and enable it
on a mac this was the easiest for me:
wget https://raw.githubusercontent.com/google/styleguide/gh-pages/intellij-java-google-style.xml
then cmd+, code style > Java > Scheme (select the gear icon) > import scheme > IntelliJ IDEA code style XML select the intellij-java-google-style.xml wherever you stored it on your system.
You can also simply add this xml file to Intellij configuration folder
/home/USERNAME/.IntelliJIdea17/config/codestyles
Then you can make this code style the default one.
File/Settings/Editor/Code Style ==> Scheme = GoogleStyle
For the latest version(2020.3.2), as mentioned by Gob00st, to enable it by default in new projects, use File>New Project Settings>Settings for New Projects>Other Settings>google-java-format Settings