Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Eclipse - Formatting Switch Statement

At the moment I have:

    switch (numberString) {
       case "FOUR": number = 4; break;
       case "FIVE": number = 5; break;
    }

It's a simple switch statement, but if I use Eclipse's format key, Ctrl+Shift+F, all of a sudden it turns into something 10 lines longer by breaking up case, value =, and break; all on to different lines.

Is there anyway to change the formatter to ignore switch statements?

like image 420
aNobody Avatar asked May 21 '15 01:05

aNobody


People also ask

How do I turn off code formatting in Eclipse?

Disable formatting for a piece of codeGo to Window > Preferences > Java > Code Style > Formatter.


1 Answers

I'm using Eclipse Oxygen 3a and I found the setting to indent the case statements within switch cases:

Preferences > Java > Code Style > Formatter > Edit... > Indent

Check Statements within 'switch' body

enter image description here

like image 75
cbaldan Avatar answered Oct 01 '22 16:10

cbaldan