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
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.
String result = str. trim(); The trim() method will remove both leading and trailing whitespace from a string and return the result.
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.
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.
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