I previously blogged about a method to make TextMate trim trailing spaces when it is saved. However, it had the unfortunate side effect of forcing you to save your file again after the trimming -- even if you hadn't made any changes. I've since implemented Sven Axelsson's comment on how to do it with a macro.
Prior to the previous blog post, my attempt at trimming and saving via a macro didn't work. Sven's suggestion solves that problem. Here it is, outlined a bit more verbosely:
- Create a new bundle with a command having the following features:
- Delete the default command text.
- Save: Current file
- Input: None
- Output: Discard
- Don't give the new bundle an Activation key.
- Record your macro:
- Bundles -> Macros -> Start Recording
- Select Bundles -> Text -> Converting / Stripping -> Remove Trailing Spaces in Document.
- Select Bundles ->
- Bundles -> Macros -> Stop Recording
- Save your new macro
- Bundles -> Macros -> Save Last Recording...
- Edit the name
- Click in the Activation (Key Equivalent) text field and hit Command-S.
I find it strange that Sven's is the only comment out there in Google search land explaining how to do this. So, either it is intuitively obvious to everyone but me, or I just have a Monkish fascination with trimming those pesky trailing spaces.
