Posts Tagged ‘ViM’

Formatting XML in ViM

September 11, 2012 Leave a comment

I love ViM. I use it for a lot of coding – especially non-project-based coding like creating or modifying PowerShell scripts. It’s also great for diagnosing log files or just a general purpose vanilla text editor/viewer with powerful regular expression search capabilities.

A common pattern of use is to open large minified XML files – like a Burn bundle manifest (which for Visual Studio 2012 is huge). Parsing all that information as a single line is a daunting task – one made more simple by formatting (indenting) the XML. I had a way that involved opening the file in another editor, formatting it, then saving it. But then I stumbled across another tip that inspired the following 2 commands that do all this in ViM:


This uses the default indentation ( :help c-indenting ) shipped with the main ViM distribution and works great for XML. It even provide progress by counting down the lines left to process.

Categories: Computers and Internet Tags: , ,