Code Monkey home page Code Monkey logo

strip-whitespace-on-save.tmbundle's Introduction

Strip Whitespace On Save

TextMate 2 bundle: Strips trailing whitespace from current document when saving. Works nicely with my Save On Focus Lost bundle.

Installation

  • Clone the git repo to ~/Library/Application Support/Avian/Bundles/Strip-Whitespace-On-Save.tmbundle
  • Relaunch TextMate 2

Customization

Customizing the bundle is easy.

Using .tm_properties

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

[*.csv]
scopeAttributes = attr.keep-whitespace

[*.yml]
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 ^⇧P (Show Scope) 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.

Without Using .tm_properties

If you can't (or don't want to) use .tm_properties files, just open the Bundle Editor (Bundles menu ▶︎ Edit Bundles... or pressing ^⌥⌘B) and add -text.tabular.csv in the command's Scope Selector field:

screenshot 2013-12-05 20 35 46

  • To exclude multiple file types, just add (space)-scope.namespace. For example, to exclude CSV and YAML, write: -text.tabular.csv -source.yaml.
  • To work only on specific file types, use the namespace only, without the minus sign (e.g., to strip only CSV files, write text.tabular.csv).
  • To include multiple file types, just add them separated by comma (i.e: text.tabular.csv, source.yaml, text.html.markdown).

Notes

You need to be using at least TextMate version 2.0.0-alpha.9317.

To get the most recent nightly build, open Preferences ▶︎ Software Update and -click the "Check Now" button . This will grab the latest version, rather than the one you get by just clicking the button.

Enjoy!

strip-whitespace-on-save.tmbundle's People

Contributors

bomberstudios avatar infininight avatar jonatack avatar lacyrhoades avatar meleyal avatar sorbits avatar tiennou avatar zearin avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.