Jikku Jose
Jikku Jose

Reputation: 18804

Vim plugin to tidy HTML, that can be installed through Vundle?

I have an HTML file that doesn't have any line breaks. Practically a huge portion of it is in a single line. I was trying to tidy that in Vim; I tried gg=G, which just tried to intend the first four lines that were on separate lines.

I tried that after the following commands:

:filetype indent on
:set filetype=html
:set smartindent

note:

Upvotes: 1

Views: 826

Answers (2)

Ingo Karkat
Ingo Karkat

Reputation: 172590

For reformatting and clean up of HTML, I usually pipe this through Tidy or html-beautify.js:

:%! tidy --indent yes --wrap 0 --tidy-mark no --force-output true -quiet --show-errors 0 --show-warnings 0
:%! html-beautify.js --file -

Upvotes: 0

Xavier
Xavier

Reputation: 4017

You can probably do it without plugin :)

Test this

:s/<[^>]*>/\r&\r/g

to split lines then remove spaces with

:g/^$/d

finally

gg=G

Hope it works :)

Upvotes: 1

Related Questions