I would like to execute the "reformat code" action on the entire project automatically when I press the run button. Is there any way to do this?
Asked
Active
Viewed 243 times
1
-
I think there is no way to do that and makes very little sense. There is, however, that option when you commit something and that actually makes sense. – Sam Sep 01 '17 at 07:58
-
I don't want to use android studio to perform commits, I need another way to format code automatically, and I think that when I run my project is the best moment to do that. – Victor Manuel Pineda Murcia Sep 01 '17 at 08:14
-
You can reformat your entire project by selecting the project node in the Project view and then clicking on `Code > Reformat Code`. This is an on demand reformat rather than an 'automatic' one but if you reformat everytime you run your project you will (a) add time to each run and (b) the reformat may be redundant since not every run will be associated with code changes. – glytching Sep 01 '17 at 08:26
1 Answers
4
I see two possibilities:
Configure action
Run
andReformat code
tothe same keyboard shortcut
Use
reformat on save
.
P.S. In any project there must be a VCS. Working with it inside IDEA is really good and you should learn how to use it. There is a native reformat on commit
checkbox in the commit dialog.

Sam
- 1,832
- 19
- 35
-
Thanks for your answer, I will choose one of them. Thanks you so much. – Victor Manuel Pineda Murcia Sep 01 '17 at 10:18
-