How do I reduce the two-tab indent of multi-line statements to one tab in Eclipse?

1k views Asked by At

For instance, if I'm defining a StringBuffer and I append to the constructor, it will give me two tabs on the append:

Foobar sb = new Foobar()
        .append(condition ? "Content" : "Other content")
        .append(conditional ? "More content" : "Even more content");

I want only one tab, which makes sense because I'm never going to tab something after the initial line of Foobar unless it's in a block, so the second tab is entirely pointless:

Foobar sb = new Foobar()
    .append(condition ? "Content" : "Other content")
    .append(conditional ? "More content" : "Even more content");

I looked through the Editor settings for Java in Preferences and could only find a way to insert tabs as spaces, which I would never do (I love my tabs).

1

There are 1 answers

1
aryn.galadar On BEST ANSWER

I'm not sure what version of Eclipse you're on, but on 4.3, you should be able to set up custom style formatter (or edit existing ones) from Window->Preferences->Java->Code Style->Formatter. Then create a new custom profile or edit an existing one.

On the actual profile edit window, it'll be under the Line Wrapping tab, then the "Default indentation for wrapped lines" option on the left.