Skip to content


Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
TextMate 2 bundle: Strips trailing whitespace from current document when saving
branch: master

Merge pull request #11 from tiennou/master

Make the whitespace stripping dependent on attributes
Failed to load latest commit information.
Macros Make the whitespace stripping dependent on attributes Merge pull request #11 from tiennou/master
info.plist Initial import

Strip Whitespace On Save

TextMate 2 bundle: Strips trailing whitespace from current document when saving. Works nicely with my Save On Focus Lost bundle. If you need whitespace highlighting, check the superb Whitespace bundle by Mads Hartmann. If you happen to need new lines at EOF, then check Mike Szyndel's Ensure New Line at the EOF bundle, which is based on mine.


  • Clone the git repo to ~/Library/Application Support/Avian/Bundles
  • Relaunch TextMate 2

Strip Whitespace on specific filetypes

If you want to customize how the bundle works, it's easy.

Say you want to avoid stripping white space on some specific files (like CSV and YAML), just add the following to your .tm_properties file:

scopeAttributes = attr.keep-whitespace

scopeAttributes = attr.keep-whitespace

If you wanted to preserve whitespace for that messed-up whitespace project of yours, just drop this in its .tm_properties file:

scopeAttributes = attr.keep-whitespace

Of course, you can combine those two approaches for complete control over whitespace-stripping !

If you want to know which scope corresponds to each language, just hit Ctrl + Shift + P ('Show Scope' command) on a document of that type, and you'll get a nice tooltip with the scope namespaces that apply at the current cursor's position.

Strip without using .tm_properties files

In any case, if you can't (or don't want to) use .tm_properties files, you can just open the bundle editor (Bundles menu › Edit Bundles... or pressing Ctrl + Alt + Command + B) and add -text.tabular.csv in the Scope Selector field of the command (see attached screenshot : )

screenshot 2013-12-05 20 35 46

If you need to exclude multiple file types, just add (space)-scope.namespace. For example, if you want to exclude CSV and YAML, you'd write: -text.tabular.csv -source.yaml.

If you want the bundle to work only on specific file types, use the namespace only, without the minus sign (i.e: if you want to strip CSV files only, you'd write text.tabular.csv). If you need to include multiple file types just add them separated by comma (i.e: text.tabular.csv, source.yaml, text.html.markdown).


You need to be using at least TextMate version 2.0.0-alpha.9317. Open Preferences » Software Update and ALT-click the "Check Now" button to get the most recent nightly build (this will grab a latest version than the one you get by just clicking the button).

Enjoy it!

Something went wrong with that request. Please try again.