I've got some poorly-formatted HTML code that I'd like to reformat. Is there a command that will automatically reformat HTML code in Sublime Text 2 so it looks better and is easier to read?
相关问题
- Views base64 encoded blob in HTML with PHP
- Is there a way to play audio on a mobile browser w
- HTML form is not sending $_POST values
- implementing html5 drag and drop photos with knock
-
Why does the box-shadow property not apply to a
There's a plugin called SublimeHtmlTidy which works pretty well
https://github.com/welovewordpress/SublimeHtmlTidy
you can set shortcut key F12 easy!!!
see detail here.
I'm using tidy together with custom build system to prettify HTML.
I have HTMLTidy.sublime-build in my Packages/User/ directory:
and tidy_config.cfg file in the same directory:
And just select build system and press ctrl+b or cmd+b to reformat file content. One minor issue with that is that ST2 does not automatically reload the file so to see the results you have to switch to some other file and back (or to other application and back).
On Mac I've used macports to install tidy, on Windows you'd have to download it yourself and specify working directory in the build system, where tidy is located:
or add it to the PATH.
For me, the
HTML Prettify
solution was extremely simple. I went to the HTML Prettify page.Sublime Package Manager
prettify
HTML prettify
selection in the menuBoom. Done. Looks great
I am yet to have the privilege to comment so this is simply additional information related to @peter's answer above answer.
I found HTML did not align as expected if IE conditional comments in the header were not completely in-line e.g. flush to the left:
I recommend this plugin: HTML/CSS/JS Prettify, It really works.
After the installation, just select the code and press Ctrl+Shift+H.
Done!