Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Eclipse formatter adds space in empty comment lines

The eclipse code formatter adds a trailing space in each empty Javadoc comment line (see screenshot).

enter image description here

The formatter of a colleague is always removing those spaces (and thus producing annoying SVN diffs). He is claiming to use the same formatter settings (XML file). Nevertheless, I tried all the options in the comments tab of the formatter settings page - without success.

Can it be a difference between eclipse versions? (I am using Springsource Tool Suite 2.7.1, which is based on Helios, I believe)

like image 345
Elbonian Avatar asked Aug 10 '11 09:08

Elbonian


2 Answers

Go to Preferences -> Java -> Editor -> Save actions and select Format edited lines.

After applying changes all trailing whitespaces in Javadoc will be removed

Note: "Additional actions"->"Remove trailing white space on all lines" must also be enabled.

like image 62
ZhekaKozlov Avatar answered Oct 30 '22 20:10

ZhekaKozlov


I found that if you go to Preferences → Java → Editor → Content Assist → Save Actions the following configuration works most of the time:

  • ☑ Perform the selected actions on save
    • ☐ Format source code
  • ☑ Additional actions
    • Remove trailing white spaces on all lines

(That is to say, turn off the Format source code option in Save Actions, but keep the Remove trailing white spaces on all lines in Additional actions on.)

The formatter and save actions duke it out, but save actions seems to win most of the time. The downside of this is that you need to periodically manually format the code.

This is using Eclipse Juno.

like image 11
Steve Pomeroy Avatar answered Oct 30 '22 21:10

Steve Pomeroy