At my last place of employment, my company-issued machine was a Windows laptop (a Dell…don’t get me started). In my search for a code editor for the Windows platform, I was naturally drawn (mainly by lack of decent alternatives) to jEdit.

Over the months that I was using jEdit, I grew accustomed to using the “Strip trailing whitespace on save” feature. I liked how it cleaned up all the extraneous characters, keeping the code as lean as possible. At night when I would sit down to code with my weapon of choice TextMate (Mac only), I found that I really missed this feature.

TextMate does have a command in the Text bundle called “Remove Trailing Spaces in Document” that will strip all of the whitespace from the end of all lines in a file, but it then takes a separate Cmd-S to save the document.

So I combined the two commands into this TextMate macro and bound it to Cmd-S. Enjoy.

Download