Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Removing trailing spaces in eclipse -- FROM THE COMMENTS

Preferences -> Java -> Editors -> Save Actions Check "Perform the selected actions on save", then check "Additional actions" and click the "Configure.." button. In the "Code organizing" tab, check "Remove trailing whitespace"

That will do the job for any normal code, however this does not look to have any effect on the comments. Is there any way to automatically get rid of trailing spaces from the commented lines?

Thanks,

p

like image 612
Sanyifejű Avatar asked Jan 26 '12 13:01

Sanyifejű


People also ask

How do I remove unwanted spaces in eclipse?

Just use C++ -> Editor -> Save Actions. Also General -> Editors -> Text Editors -> Show whitespace characters (click on it for detailed settings) is extremely handy. I couldn't figure out why suddenly white spaces at end of lines are removed, until I saw your question and found out it was becuase of AnyEditPlugin.

How can I remove the trailing spaces from a string?

String result = str. trim(); The trim() method will remove both leading and trailing whitespace from a string and return the result.

How do I get rid of trailing spaces in Java?

To remove leading and trailing spaces in Java, use the trim() method. This method returns a copy of this string with leading and trailing white space removed, or this string if it has no leading or trailing white space.


1 Answers

This is something i've tried to remove trailing space:

Window->Preferences Jave->Editor->Save Actions Enable Perform the selected actions on save. Enable Additional actions. 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.

Review the other options under Save Actions, since these will also happen automatically now. Don't forget to click Apply in the Save Actions preference page. it should be fine.

like image 71
Ricardo Avatar answered Sep 19 '22 15:09

Ricardo