Auto code formatting in Android Studio

Another option would be download the save actions plugin from jetbrains officials (as the search inside the plugin section in IDE doesn't find it)

Next, import the downloaded JAR file through IDE settings:

File > Settings > Plugins > Install plugins from disk

Restart the IDE and the Save Actions configuration will be shown on the root of IDE Settings


Using Flutter to auto format code when saving: tick - File|Settings|Language & Frameworks|Flutter - 'Format code on save'.


It is not possible other than via a macro. There is an outstanding feature request -- IDEABKL-5806 Automatically trigger code formatter on file save -- for such an action. There a bit of discussion on the ticket you may want to read. I recommend you vote for it. It is however a 4 year old request. And based on comments by JetBrains, it does not appear like it is a high priority item. Additional votes may change that.

In the meantime, using the auto format on commit option would be an option for you.

Finally, if you want an easier way to set up the macros on other developer's systems, the macros are stored in the file .IntelliJIDEA/config/options/macros.xml (see Directories used by the IDE to store settings, caches, plugins and logs for more information on the location of the config directory). Keymaps are stored in .IntelliJIDEA/config/keymaps/{map-name}.xml You could copy those files over.