Last Updated: May 15, 2019
·
3.966K
· 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

2 Responses
Add your response

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

over 1 year ago ·

And beware if you have SVG embedded.

over 1 year ago ·