Adding auto-format code indenting to Sublime Text 2

While looking for a way to simplify indenting multiple lines with Sublime Text 2 I came across a useful way to auto-format code indenting (similar to the auto-format function in Processing).

To add the keybinding in Sublime Text, select Key Bindings – User in Preferences. Next, add the following line in between the square brackets.

{ "keys": ["super+t"], "command": "reindent", "args": {"single_line": false} }

Pressing command+t will auto-format your entire document. (I chose command+t to match Processing’s auto-format keybinding, but you can use any keyboard shortcut you like.) You can also change the “single_line” argument to true if you’d just like auto-format to run on your selected lines. Enjoy!