I am learning Vim but I thought this was a simple task but I cannot get it to work. I have browser SO but the solutions are not working for me.
I am trying to correc
Use an external program to indent your xml files. In this case I've choosen xmllint, so set the command to the equalprg option:
:set equalprg=xmllint\ --format\ -
Now you can execute
gg=G
to let xmllint format your xml files.
To get it every time you use vim, use an autocommand to set it.
autocommand from a comment below
au FileType xml setlocal equalprg=xmllint\ --format\ --recover\ -\ 2>/dev/null