[wingide-users] Trim whitespace at end of lines?

Wingware Support support at wingware.com
Mon Aug 29 16:31:13 EDT 2005

On Sat, 27 Aug 2005, Michael Hipp wrote:
> Is there an option somewhere to have the editor automatically trim whitespace 
> at the end of all lines (probably upon file save)?

The following added into scripts/editor_extensions.py should work as 
a way to do it on demand:

def remove_trailing_whitespace(app=wingapi.kArgApplication):
  """Remove trailing white space in current editor"""

  eol = '\n'
  def filter(txt):
    return eol.join([t.rstrip() for t in txt.splitlines()])
  _buffer_convert(app, filter)

Change eol to the line ending style you want or of course you could 
check the text and restore the same style.

You can bind this to a key binding in preferences or set the contexts 
attribute (see Scripting chapter in docs) to get it into a menu bar 
menu or the editor context menu.

I've noted your request for doing it automatically all the time.
Thanks for the suggestion.

- Stephan

More information about the wingide-users mailing list