2

In Eclipse IDE (or in my case STS) for a java file about: remove trailing white spaces on all lines I am able to do the following:

enter image description here

Practically how is described in:

Thus from the figure shown above you can see:

  • Remove trailing white spaces on all lines

Until all work fine, but for development, we have files with other extensions. Thus I need have the same feature for a non java file, for example for: .xml, .js, .gradle, .html, .css, .properties, .sql files, etc.

I could not find a specific section to accomplish this.

How I can accomplish this required configuration?

Manuel Jordan
  • 15,253
  • 21
  • 95
  • 158
  • It is up to the individual editors to implement this. If it isn't listed in the preferences for a particular editor it isn't supported by the editor. – greg-449 Aug 14 '18 at 18:51

1 Answers1

5

Unforunately there is no generic solution to automatically remove trailing whitespace in Eclipse. See:

However, there is a plugin named AnyEdit Tools which removes trailing whitespace on any file, with no configuration necessary beyond installing the plugin and restarting Eclipse.

There are two ways you can install it:

  1. Using Help -> Install new Software...

    • Enter http://andrei.gmxhome.de/eclipse/ as the URL in the Work with field.
    • Select AnyEditTools option for all recent releases of Eclipse (3.8+), and complete the wizard.

      installAnyEditTools

  2. Using Help > Eclipse Marketplace...

    • Enter AnyEdit in the Find field to locate the AnyEdit Tools plugin.
    • Click the Install button.

      installAnyEditTools2

Once Eclipse is restarted the plugin should automatically remove trailing spaces on any file when you save it, regardless of type or extension. For example:

  • Create a new file with some arbitrary extension unknown to Eclipse (e.g. test.abcxyz).
  • Enter some data in the file, with some lines having trailing spaces.
  • Save it. The trailing spaces are gone.

This plugin works for me on Photon.

AnyEdit can do a lot of other things as well. This is the summary for the installed plugin:

Adds useful context menu actions to text files and editors - Open file, type under cursor, Convert tabs to spaces, case, html, base64, unicode, Compare/Replace with clipboard or external files etc. AnyEdit can remove trailing whitespace and/or convert tabs-spaces on save and contributes Import/Export working sets wizards.

See the web site for the plugin for more details.

skomisa
  • 16,436
  • 7
  • 61
  • 102
  • Thanks for the reply, consider add the Marketplace option too. It with the purpose to share the two options to install it. – Manuel Jordan Aug 14 '18 at 19:18
  • 1
    @ManuelJordan OK - I verified that the plugin also works when installed through the MarketPlace option and updated the answer, and also added the plugin's summary of its features. – skomisa Aug 14 '18 at 19:55