How to format an unformatted XML document using gVim?

I often open XML documents in gVim on Windows, which end up having everything on one line. I manually executed the search and replace command:

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

to get all the fields on separate lines, then manually print the lines. This will not work with large files and is in any case inefficient in any file size.

Is there a way built into gVim, or is there a tool (preferably in gVim) available to help me format my XML documents in separate lines from its single line, which opens by default in gVim?

+6
source share
1 answer

Does it do the trick?

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

It is easily called when necessary, using:

 :PrettyXML 
+7
source

Source: https://habr.com/ru/post/956947/


All Articles