[TxMt] Current state of the art in stripping trailing whitespace automatically on save?

John Yeates textmate2 at warmvomit.co.uk
Sun Jul 8 21:12:02 UTC 2012

I've (once again) got fed up with saving things only to find that git is rejecting the commit due to trailing whitespace, and have had another look at automatically stripping it.

I've tried the bundle at https://github.com/bomberstudios/Strip-Whitespace-On-Save.tmbundle, which hasn't been working for me for ages, and the solution at http://reinteractive.net/posts/4-stripping-whitespace-out-of-textmate-2, which saves the file with the whitespace unstripped and *then* strips the whitespace (and unhelpfully moves the cursor to the end of the document, too). None of them results in me achieving my goal of a file on disk which doesn't have trailing whitespace, and a buffer in TextMate which shows as saved.

Is there some solution I'm missing?

(The ideal would be for whitespace stripping to be built in, not just as a manually-executed command in the Source bundle, but something in the app preferences that could also be turned on/off in .tm_properties — that would mean every TM2 user cloning a no-trailing-whitespace-allowed repo would get a .tm_properties file that causes it to do the Right Thing for that project, regardless of how the user has their preferences set up. Allan, is there any chance of this in a future build?)


John Yeates

More information about the textmate mailing list