Changing TextMate JavaScript reformat tab size
TextMate has an beautify command built into its default JavaScript bundle ⌃⇧H (Ctrl+Shift+H). To change the tab size used by the beautifier:
- Crack open the Bundle Editor. Bundles > Bundle Editor > Show Bundle Editor or ⌃⌥⌘B (Ctrl+Cmd+Opt++B)
- Select JavaScript > Reformat Document / Selection
- Add a second argument for the number of spaces to
js_beautify($input)
For mine, with two space tabs, it looks like:
print js_beautify($input,2);
If you want to hack the PHP script that makes it all happen, you’ll find it in /Applications/TextMate.app/Contents/SharedSupport/Bundles/JavaScript.tmbundle/Support/lib/beautify.php
Thanks to help from Ryan Stout.