Home > Computers and Internet > Formatting XML in ViM

Formatting XML in ViM

September 11, 2012 Leave a comment Go to comments

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: , ,
  1. No comments yet.
  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: