문제

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?

도움이 되었습니까?

해결책

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.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top