40

Ideally, eclipse should remove all trailing whitespace when I save the file. I know there is option for this in C++/Java plugins for eclipse, but I couldnt find one for PyDev. Is there one? If not, whats the easiest way to achieve this?

vinodkone
  • 2,731
  • 4
  • 22
  • 21

2 Answers2

46

Check in:

Preferences > PyDev > Editor > Code Style > Code Formatter

and check the "Right trim lines?" check box.

TorelTwiddler
  • 5,996
  • 2
  • 32
  • 39
  • 3
    This only seems to do anything when you call the auto-formatter(shift+ctrl+f). Is there no way to strip trailing whitespace on save? Even the simplest text editors have that.. – cib Oct 13 '13 at 11:45
  • 3
    You can check the 'auto-format editor contents before saving' check box. – bigmonachus Jan 07 '14 at 20:52
  • 11
    The only problem with this method is that there is no way to _only_ right trim lines. All of your code will be formatted, whether you want it or not, using the code formatter. Using AnyEdit like @LPunker suggests is what people want if they only care about trailing whitespace. – Cody Piersall Apr 25 '14 at 00:49
12

i stumbled accros this usefull [site][1]

[1]: http://andrei.gmxhome.de/anyedit/ hope this could help

LPunker
  • 603
  • 4
  • 6
  • 4
    Actually anyedit is more generally useful as it can strip whitespace, convert tabs to spaces, add newline at the end of the file... in any text editing window, not only in pydev. See also [this question](http://stackoverflow.com/questions/1043433/how-to-auto-remove-trailing-whitespace-in-eclipse?rq=1) – Fred Schoen Dec 29 '13 at 23:39