Is it possible to format code automatically on save
? I've seen a solution in which a macro assigned to a shortcut is proposed but I need to be able to make this a project setting. This way, anyone joining our project doesn't have to configure a macro for himself.
In Eclipse this was easily achieved using save actions
and putting the config files under version control. Is this possible with Android Studio?
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.