Question

i am trying to adjust the code formatter settings in eclipse to my wishes.

That is my (unformatted) example code:

public class Test {    
    /**
     * Test 1.
     */
    public void test() {
        System.out.println("Blub");
    }

    /**
     * Test 2.
     */
    public void test2() {
        System.out.println("Blub");
    }




}

After formatting (eclipse standard settings) the code looks like this:

public class Test {
    /**
     * Test 1.
     */
    public void test() {
        System.out.println("Blub");
    }

    /**
     * Test 2.
     */
    public void test2() {
        System.out.println("Blub");
    }

}

I tried everything to adjust the formatter settings to get this result:

  1. Add a blank before the first java doc comment.

  2. Remove the last blank line (before the closing braces of the class declaration).

How can i achieve this or is it not possible to configure this in eclipse?

Was it helpful?

Solution

I would say it's going to be under the 'blank lines' section of the formatter settings.

(Blank lines within class declarations) -> Before first declaration. Try setting to 1.

(Existing blank lines) -> Number of blank lines to preserve (This is the setting where you can get Eclipse to remove blank lines in places not specified by the other rules). Try setting to zero.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top