4

When I format an enum using Ctrl + Shift + F in Eclipse It does not add a new line after each element in enum. Like this

public enum MyEnum
{
    ELEMENT(0),ELEMENT(1);
}

But I need a format like this:

public enum MyEnum
{
    ELEMENT(0),
    ELEMENT(1);
}

How can we configure Formatter in Eclipse to add new line after each element in enum?

Cœur
  • 37,241
  • 25
  • 195
  • 267
वरुण
  • 1,237
  • 3
  • 18
  • 50

1 Answers1

7

Go to Line Wrapping in Java Formatter. Expand 'enum' declaration and choose Constants. Select Wrap all elements, every element on a new line in Line wrapping policy and check Force split, even if line shorter than maximum line width. Apply and OK.

Aleksandr M
  • 24,264
  • 12
  • 69
  • 143