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

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

    It's not nice but you can turn the Eclipse formatter off for some sections of code...

    // @formatter:off
    public static enum Command {
        login,
        register,
        logout,
        newMessage
    };
    // @formatter:on
    

    the option is in the Windows->Preferences->Java->Code Style->Formatter->Edit->Off/On Tags panel

提交回复
热议问题