[TxMt] saving without trailing spaces and tabs...

Dan Ridley danridley at mac.com
Tue Mar 21 16:48:42 UTC 2006


There's a command - Text / Remove Trailing Spaces in Document. You  
could bind that, or your macro, to Cmd-E (right next to S on the  
keyboard), so you could remove spaces and save by holding Cmd and  
tapping E-S.

If you really want to get it into one command, you can use this:

perl -pe 's/[\t ]+$//g' > "$TM_FILEPATH" && cat "$TM_FILEPATH"

  (Input: Entire Document
   Output: Replace Document)

There are two problems with this, though:

  * TextMate will not know that you've overwritten the file, so while  
the file contents on disk will match the file contents in TextMate,  
you'll still get the "unsaved" bullet on your tab, and will be  
prompted to save on close.
  * You'll be returned to the beginning of the current line when you  
run it.





More information about the textmate mailing list