Last Updated: February 25, 2016
·
4.122K
· supersymmetry

Front-end web development tricks in Vim: Uncompress HTML

Vim is a very powerful and versatile editor, I like to use it as my IDE for any code work, for example some front-end web development in HTML5/CSS3 and optionally JavaScript frameworks.

In the rare occasion I find compressed HTML, this is a way to reformat it quickly in vim using regular expressions.

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

Which will split all <tags> to their own lines. In order to remove the empty spaces use:

:g/^$/d

After which you can use

=

Thanks to Chris Morgan

3 Responses
Add your response

If you have Tidy installed on your machine, it gets even easier. http://coderwall.com/p/lb-obq

over 1 year ago ·

Probably yes :) I have Steve Francia's SPF13 setup...and with all those plugins in vundle, there must be countless more ways you could do this

over 1 year ago ·

Thanks for this. I'm sure there might be some more elegant way to make this happen but you still managed to save me 15 minutes of my life ;)

over 1 year ago ·