o3fnhg
Last Updated: February 25, 2016
·
3.346K
· supersymmetry
Me2

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

Say Thanks
Respond

3 Responses
Add your response

310
D21ebccf20562e370eb0a8cf170a0580

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

over 1 year ago ·
320
Me2

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 ·
21854
Avatar 73 normal

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 ·