From TextMate Wiki

HowTo: CustomizeTidy

The command _Bundles → HTML → Tidy_ is a wrapper for the [`tidy`][tidy_1] shell command included with Mac OS X.

If you install another version of `tidy` you can either [update your search path][] to have the location of this version be found first, or set the `TM_TIDY` [environment variable][] to `/path/to/new/tidy`.

The `tidy` tool has an [extensive manual][] and a [quick references][] page where you will find a lot of settings which affect how `tidy` will process your HTML document.

To see the default settings run `tidy -show-config` in a shell (terminal). TextMate will call `tidy` with a few configuration options which can be seen by locating the Tidy TextMate command via the bundle editor, see _Bundles → Bundle Editor_.

The Tidy TextMate command is doing a little more than just calling `tidy`. We [enable XHTML mode][] only if you have set `TM_XHTML`, we make the output [use soft tabs][] if your settings indicate that, we do not include HTML boilerplate (doctype, html, and body tags) if you invoke the action with a selection, and similar.

If you want to alter how the default Tidy in TextMate works you have two options.

 1. Edit the command. Advantage: should be straightforward. Disadvantage: if the default command is updated, TextMate will continue to use your customized version (see [how to revert bundles][]).

 2. Set the `HTML_TIDY` [environment variable][] to point at a configuration file and place your options in this file. In addition to leaving TextMate’s Tidy command pristine, it will allow you to set [project-specific preferences][] for `tidy`, which might be useful for example if you have different projects in which you want it to use different document types.

[tidy_1]: [extensive manual]: [quick references]:

[environment variable]:

[update your search path]:

[how to revert bundles]: ../Troubleshooting/RevertToDefaultBundles

[project-specific preferences]:

[enable XHTML mode]: EnableXHTMLTags [use soft tabs]: UseSpacesInsteadOfTabs

  1. Page Notes

We should add an example of how to do #2

We may want to drop our default config options (in the TextMate Tidy command) if the `HTML_TIDY` environment variable is set (so we do not eclipse user’s config options).

Retrieved from
Page last modified on November 11, 2008, at 21:38 UTC