Skip to content
Advertisement

Rearrange modifier keywords in IntelliJ

Is there any way to automatically rearrange modifier keywords in IntelliJ?

For example, if I have the following code:

private final static int x = 0;
final private static int y = 0;
static final private int z = 0;

Rearrange it to:

private final static int x = 0;
private final static int y = 0;
private final static int z = 0;

Advertisement

Answer

Go to Settings and enable the Editor | Inspections | Java | Code style issues | Missorted modifiers inspection. It has a quick fix to sort the modifiers. This inspection is also part of Analyze | Code Cleanup…, so another solution would be to invoke that on your code.

Advertisement