nimo23
nimo23

Reputation: 5680

eclipse formatting new lines at each method property

How can I set up eclipse formatter, to format a method-body to this:

// I want to have a new line on each method property:
public void test(
    double a, 
    double b, 
    String c, 
    Object f
) {
    a = 4;
    b= 3;
    c = "hello";
    f = null;
}

Upvotes: 2

Views: 3651

Answers (1)

howlger
howlger

Reputation: 34135

Create a new Eclipse formatter profile based on the Eclipse [built-in] profile and change the following:

  • In the Line Wrapping tab, choose Method Declarations > Parameters:
    • Set Line wrapping policy to Wrap all elements, every element on a new line
    • Check Force split, even if line is shorter than maximum line width
    • Set Indentaton policy to Indent by one
  • In the Parentheses tab, set Method declaration to Separate lines

Upvotes: 4

Related Questions