Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I format an unformatted XML document using gVim?

I often open XML documents within gVim in Windows which end up with everything on one line. I manually do a search and replace command:

:%s/></>\r</g

to get all fields on individual lines then tab out manually the lines. This isn't going to work with sizable files, and isn't efficient in any size file anyways.

Is there a way built into gVim or is there a tool (preferably in gVim) available to help me format my XML documents into separate lines from its one line version that open up by default in gVim?

like image 208
DemiSheep Avatar asked Oct 29 '13 13:10

DemiSheep


1 Answers

Does this do the trick?

http://vim.wikia.com/wiki/Pretty-formatting_XML

It's easily invoked as needed using:

:PrettyXML
like image 141
gap Avatar answered Oct 02 '22 02:10

gap