Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to specify the order of class members when formatting in Eclipse

Tags:

eclipse

In Eclipse IDE how do you customize the Java code style formatter to have it sort the class members with a specified order, for example to group all instance methods by visibility?

like image 677
Joel Avatar asked Sep 19 '25 18:09

Joel


2 Answers

If the question is, "how do you customize the 'Source -> Format' command to re-order members?", I don't think it can be done. To change the order used for the 'Source -> Sort Members' command, change the "Members Sort Order" preference: "Window -> Preferences -> Java -> Appearance -> Members Sort Order"

like image 59
Chris Conway Avatar answered Sep 23 '25 06:09

Chris Conway


I'm not sure when they added this functionality, but it seems to be there in 3.5:

Window -> Preferences

Java -> Editor -> Save Actions

Additional actions -> Configure ...

Code Organizing -> Members -> Sort Members


Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!