Altough the question is for HTML, I would also additionally like to give info about how to auto-format your Javascript code for Sublime Text 2;
You can select all your code(ctrl + A) and use the in-app functionality, reindent(Edit
-> Line
-> Reindent
) or you can use JsFormat formatting plugin for Sublime Text 2
if you would like to have more customizable settings on how to format your code to addition to the Sublime Text's default tab/indent settings.
https://github.com/jdc0589/JsFormat
You can easily install JsFormat with using Package Control (Preferences
-> Package Control
) Open package control then type install, hit enter. Then type js format
and hit enter, you're done.
(The package controller will show the status of the installation with success and errors on the bottom left bar of Sublime
)
Add the following line to your key bindings (Preferences
-> Key Bindings User
)
{ "keys": ["ctrl+alt+2"], "command": "js_format"}
I'm using ctrl + alt + 2, you can change this shortcut key whatever you want to. So far, JsFormat
is a good plugin, worth to try it!
Hope this will help someone.