How to stop Eclipse formatter from adding trailing whitespaces in Javadoc

eclipse, formatter, java, javadoc, whitespace

Solution

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).

Problem

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?

Original source