user1796942 user1796942 - 1 year ago 59
Java Question

Is there a way to automatically remove trailing spaces in Eclipse?

Is there a way to automatically remove trailing spaces in Eclipse?

I see there are nice functionality in Source like Correct Indentation and Format.
But they dont remove trailing spaces.

Thanks

PS: What other functionalities of this kind you use to make the code nicer?

Answer Source

It's available as a Save action, at least. (I can't see it under the formatter options.)

Go to Window / Preferences, Java / Editor / Save Actions. Tick "Additional Actions" and click on Configure. In the "Code Organizing" tab, the first option is "Remove trailing whitespace".

Note that this will remove all trailing whitespace from Java files - not just those you've touched. If you're working with people who don't remove trailing whitespace, this can be messy in terms of later doing a diff.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download