IntelliJ sort enum members
Asked Answered
G

2

12

Is there any way to sort the member variables of an enum alphabetically in IntelliJ? I've been trying a bunch of different settings in the arrangement section but didn't have success. Could anyone maybe help me?

Gertrude answered 6/11, 2018 at 15:27 Comment(0)
C
32

Type Alt+Enter on an enum constant and invoke the sort content intention. This will sort the enum constants in alphabetical order. The intention will only appear if the constants are not alphabetically sorted.

Chiliarch answered 6/11, 2018 at 18:0 Comment(0)
G
2

Wasn't able to find the same action for AndroidStuido, instead, I used Menu -> Edit -> Sort Lines

Good thing is that it can be used for anything :)

enter image description here

Grus answered 6/12, 2022 at 11:44 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.