Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can you set up Eclipse to remove trailing whitespace when saving a JavaScript file?

I am running Eclipse 3.6 (Helios 20110218-0911) on Ubuntu 11.04. Under Preferences, I have gone to the following panel:

JavaScript -> Editor -> Save Actions.

The "Additional actions" checkbox is checked and "Remove trailing whitespaces on all lines" is selected.

enter image description here

Nevertheless, when I save my JavaScript file in Eclipse, there is still trailing whitespace at the end of my lines.

What am I missing?

like image 321
bolinfest Avatar asked Sep 27 '11 19:09

bolinfest


People also ask

How do you remove trailing and leading spaces in JS?

trim() method is used to remove the white spaces from both the ends of the given string. Return value: This method returns a new string, without any of the leading or the trailing white spaces. In this example the trim() method removes all the leading and the trailing spaces in the string str.

How do I remove trailing spaces from a file?

Method One: sed A simple command line approach to remove unwanted whitespaces is via sed . The following command deletes all spaces and tabs at the end of each line in input. java . If there are multiple files that need trailing whitespaces removed, you can use a combination of find and sed commands.

Which method is used to removes leading and trailing whitespace?

Use the Trim() method to remove leading and trailing whitespace from a string. Let's say the following is our string with white spaces in the beginning and the end. String str = " a "; Now, use the trim() method.


1 Answers

'Save Actions' for JavaScript is available in the JavaScript project(the project with JavaScript nature) only.
(If you can see 'Convert to JavaScript Project' in 'Configure' menu when right-click the project, try it)

like image 157
atlanto Avatar answered Oct 11 '22 10:10

atlanto