How to stop Eclipse formatter from placing all enums on one line

后端 未结 6 764
感情败类
感情败类 2021-01-30 03:55

I have enums like:

public static enum Command
{
login,
register,
logout,
newMessage
}

When formatting the file, the output becomes:

<         


        
6条回答
  •  轮回少年
    2021-01-30 04:24

    Just adding latest Eclipse 2018.9

    1. Window > Preferences > Java > Code Style > Formatter - Edit
    2. Expand Line Wrapping tree node.
    3. Expand Wrapping settings
    4. Expand 'enum' declaration
    5. Edit Constants and Constant arguments.

    Constants need to be Wrap all elements, every element on a new line. Constant arguments need to be Wrap where necessary.

提交回复
热议问题