For auto-formatting, I suggest using the Fmt plugin (available on Package Control or from https://github.com/mitranim/sublime-fmt) which lets you configure formatters for any amount of languages. It works by shelling out to a CLI formatter you have installed on your system. For HTML, I use deno fmt (since I also use Deno for other stuff). This requires the following in your Fmt.sublime-settings:
{
"rules": [
{
"selector": "(text.html - text.html.markdown)",
"cmd": ["deno", "fmt", "-", "--ext", "html"],
"env": {"NO_COLOR": "true"},
"format_on_save": true,
},
],
}
If format_on_save is undesirable, drop that line and add the following to your keymap (change the keys if you want):
{"keys": ["primary+k", "primary+j"], "command": "fmt_format_buffer"}