Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to stop Eclipse formatter from adding trailing whitespaces in Javadoc

I noticed an odd behavior of the Eclipse formatter (Strg+Alt+F) when running it on a piece of code like this:

/**
 * bar
 *
 * @return nothing
 */
Object foo() {
    return null;
}

It will add a trailing space character here:

/**
 * bar
 * <--- this line has a trailing space now!
 * @return nothing
 */
Object foo() {
    return null;
}

I know how to configure Eclipse to remove trailing whitespace, but it there a way to stop the formatter from adding it in the first place?

like image 922
friederbluemle Avatar asked Apr 02 '13 03:04

friederbluemle


People also ask

How do I remove unwanted spaces in eclipse?

Click Configure. In the Code Organizing tab., enable Remove trailing whitespace for All lines. Review all the other options there, since it will all happen automatically whenever you save -- make sure there isn't anything there you don't want. Dismiss the Configure window.

What are trailing Whitespaces?

Trailing whitespace is any spaces or tabs after the last non-whitespace character on the line until the newline.


1 Answers

You can just go to Preferences -> Java -> Editor -> Save Actions and configure it to remove trailing whitespace.

In order to do that right-click on your project and go to Properties -> Java Editor -> Save Actions. From there you can enable project specific settings and configure it to remove trailing whitespace (among other useful things).

like image 191
Linga Avatar answered Sep 18 '22 15:09

Linga