Using tidy from within vim to clean up current buffer.
Mar 13 2010Scraping some XML feeds recently left me with some pretty hard to read markup and I need to clean it up. I have used tidy in the past but never from within my editor. After a little reading and testing I came up with the following vim command that will take the current vim buffer (which is XML) and update it as tidy
.
:%!tidy -i -q -w 0 -xml
You can use any of tidy's command line arguments. For example you could convert an HTML document to XHTML with the following:
:%!tidy -i -q -w 0 -asxhtml