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

后端 未结 6 712
感情败类
感情败类 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:09

    You can specify this in your formatter preferences:

    • Preferences: Java -- Code Style -- Formatter
    • Click Edit
    • Select the 'Line Wrapping' tab
    • Select 'enum' declaration -> Constants in the box on the left
    • Set Line wrapping policy to 'Wrap all elements, every element on a new line'
    • Check 'Force split...'

提交回复
热议问题