Wednesday, January 8, 2014

Format XML with VIM + Indentation



Formatting XML in VIM is one of the most annoying things.  It is always easier to use other tools and paste the results back in VIM.  When you have to edit XML files very often it becomes a problem.

Recently a friend of mine and Sys Admin guru Kyle Douglas sent me an email with the VIM command to complete the task:

:silent %!xmllint --encode UTF-8 --format -

If you work with XML very often, this can be mapped to a key for easy access (in this example the F1 key).


:nmap :silent %!xmllint --encode UTF-8 --format -<CR>

Thanks for the info Kyle,


Ricardo Ramirez

No comments:

Post a Comment