indenting XML in vim

Sometimes I need to look inside XML files which consist of one big line. It’s very impossible, and reformatting takes a time. Fortunately, I’ve found a good solution for vim.

I added to my “.vimrc” file:

map <F2> <Esc>:1,$!xmllint --format -<CR>

Now I can press “F2″ button, and vim indents the text.

More hints on indenting XML in vim: Tip #349: Format your xml document using xmllint.

One Response to “indenting XML in vim”

  1. Rick Says:

    Thanks. Quick hit on google and did what I needed.

Leave a Reply