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?
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.
You can easily remove all the trailing whitespace within a single file by using a regular expression with the Find/Replace dialog. Enter [ \t]+$ in the "Find:" box and leave the "Replace with:" box empty. Check the "Regular expressions" option then click "Replace All"
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With