2010-06-23

Make a single-line XML stream pretty in vim

Usually I view XML in Firefox as that's the quickest way to get a nice tree I can explore. But when I might want to edit it until today I've been loading it into vim and then if necessary adding newlines manually or using a fairly dumb regex to do it for me. Today I made a slightly more sophisticated one.

:%s/>\s*</>\r</g adds the newlines in decent places and then gg=G indents it all.

No comments:

Post a Comment