Indent XML/HTML in Vim
Posted: Thu Nov 03, 2016 1:43 am
I've been using vim to beautifully indent XML or HTML files on a daily basis.
Nevertheless, I've stumbled over a new combination of vim-foo by Rajashekar Chintalapati today:
The magic spell formula again, in ONE row (just to try being cool):
Nevertheless, I've stumbled over a new combination of vim-foo by Rajashekar Chintalapati today:
- First join all the lines - ggVGgJ
- Now break tags to new lines - :%s/>\s*</>\r</g
- Now set filetype - :set ft=html (you can do this before too)
- Now Indent - ggVG=
The magic spell formula again, in ONE row (just to try being cool):
Code: Select all
ggVGgJ :%s/>\s*</>\r</g :set ft=html ggVG=