23
4
For example, something to change:
<section><article><h1></h1><p></p></article></section>
to:
<section>
<article>
<h1></h1>
<p></p>
</article>
</section>
...that works on full pages and snippets.
- The built in
Edit > Line > Reindent
setting doesn't do this - The plugin HTMLTidy adds
head
andbody
tags, so it doesn't work for partials, it also has various other issues - The plugin Tag has various issues, enough that it essentially doesn't work
- The plugin HTMLPrettify has various issues, requires node.js, and hasn't been updated in months
- gist.github.com/mcdonc/3898894 claims to do it, but requires Emacs
(Notepad++ had auto-indent, Dreamweaver had Apply Source Formatting, Aptana has Format, etc.)
The Tag plugin handles inline tags incorrectly, for example using it on this snippet:
<p>foo<a>bar<span>baz<span>qux</span></span></a></p>
results in:
<p>
foo
<a>
bar
<span>
baz
<span>qux</span>
</span>
</a>
</p>
I think this is the best working solution: http://jsbeautifier.org/ I've had the same requirement of format multiple inline tags. This one works really well. It create proper markup for sublime text as well which can close chunks. It's also available on CLI as https://www.npmjs.com/package/js-beautify
– Sai krishna Deep – 2016-12-26T15:39:57.257What is the question? It's not clear from your post what the question is. – Brad Patton – 2013-03-11T14:56:18.023
Edited title to be interrogative. I'm trying to find some way to auto-indent HTML in Sublime Text. – user110241 – 2013-03-11T15:07:32.243
Also see Formatting HTML Code using Sublime Text 2.
– Karan – 2013-03-11T19:39:25.640Thanks, I tried each solution in that thread, none of them work. I've listed the reasons why many of them don't work in this thread. – user110241 – 2013-03-12T14:10:46.183