问题
Eclipse has tons of features, i'm wondering if this one exsists? Or if any shortcut ways of doing it exist?
I want to arrange my class data into Variables, Constructors, Methods in that flow(Top to Bottom)
Further refined I would like to arrange by access level(pub, private, protected) and type - void or methods that return. The same for Vars - access level and type.
Any ideas. I mean I try to keep my code as tidy as possible. But would be nice to kind of format a class that perhaps I havent written that is messy.
回答1:
If you go the preferences screen and then go to Java -> Appearance -> Members Sort Order you can configure the sort order for members.
Next just right click when you have a file open and go to Source -> Sort members
回答2:
Under Preferences choose Java -> Appearance -> Members Sort Order. This allows you to set the order of members within a class when you use the Sort Members action.
来源:https://stackoverflow.com/questions/4107944/eclipse-feature-to-arrange-a-class-file