lb-obq
Last Updated: February 25, 2016
·
3.274K
· jacaetevha

tidied HTML in vi/vim

If you have Tidy installed, just pipe your buffer through it to get clean HTML.

:%!tidy -qicbn -asxhtml

Use "tidy -h" for more help on the options, but the ones I tend to go with are in the example above:

-indent, -i         indent element content
-clean, -c          replace FONT, NOBR and CENTER tags by CSS
-bare, -b           strip out smart quotes and em dashes, etc.
-numeric, -n        output numeric rather than named entities
-quiet, -q          suppress nonessential output
-asxml, -asxhtml    convert HTML to well formed XHTML

3 Responses
Add your response

5583

If all you want to do is fix indenting, and you have filetype=html, then you can highlight a range of text and hit "=".

over 1 year ago ·
5588

Thanks @petdance, but Tidy does much more than just fix indentation.

over 1 year ago ·
18791

And beware if you have SVG embedded.

over 1 year ago ·