Format code like google

Get easy look-alike readable code with IntelliJ

Spotless is are really cool tool for formatting your code with build tools. If you like, you can do that with your IDE too. I show your how to configure IntelliJ, so your code is automatically formatted while you save a file.

First you have to install the Google Java Format Plugin. After that please install the Save Action Plugin. Now go to File→Settings→Other Settings→Save Action and activate „Activate save action on save“. Activate the Formating Actions „Optimize imports“ and „Reformate File“ too.

Check the google-java-format setting, if the plugin is enabled. Unfortunately the import ordering is not handled by this plugin. To fix the import order, download the IntelliJ Java Google Style file and import it into File→Settings→Editor→Code Style.

That’s it. Happy coding.

Spotless Gradle Plugin
IntelliJ Google Java Format Plugin
IntelliJ Save Action Plugin
IntelliJ Java Google Style file