Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Disable rearranging methods while auto-formatting

I'm using Android Studio 2.2 and I like auto-formatting my code using ctrl-alt-L. The problem, however, is that it also reorders all of my methods. (For some reason, it wants to put all of my static methods at the top of the class.) Is there a way to disable the rearranging of methods while auto-formatting?

Note: I'm guessing that I could go into Settings -> Editor -> Code Style -> Java and under the "Arrangement" tab delete all of the "Matching rules", but there has to be a simpler way than that, no?

like image 660
Mark Cramer Avatar asked Oct 07 '16 03:10

Mark Cramer


1 Answers

From IntelliJ support at Jetbrain, you can configure default behavior for "Reformat Code" action using ctrl + alt + shift + L shortcut, where you can enable/disable Rearrange code option: https://www.jetbrains.com/help/idea/2016.2/reformat-file-dialog.html.

Also, after a reformat action (i.e. ctrl + alt + L) there will be a pop-up that will say something like, "No lines changed: code is already properly formatted. Show reformat dialog: Ctrl+Alt+Shift+L". The word "Show" will be linked to the "Reformat File Dialog" which is another way to get to the dialog to enable/disable the Rearrange code option.

Arrangement behavior can be customized in File -> Settings -> Editor -> Code Style -> Java -> Arrangement.

like image 189
Mark Cramer Avatar answered Sep 21 '22 06:09

Mark Cramer