Revision as of 03:38, 22 August 2014 by Lokvin(Message Wall | contribs)(Created page with "==install vim == yum install vim ==create ~/.vimrc == touch ~/.vimrc ==add vim format xml== * add below content to ~/.vimrc function! DoPrettyXML() " save the filetype...")
" save the filetype so we can restore it later
let l:origft = &ft
" delete the xml header if it exists. This will
" permit us to surround the document with fake tags
" without creating invalid xml.
" insert fake tags around the entire document.
" This will permit us to pretty-format excerpts of
" XML that may contain multiple top-level elements.
silent %!xmllint --format -
" xmllint will insert an <?xml?> header. it's easy enough to delete
" if you don't want it.
" delete the fake tags
" restore the 'normal' indentation, which is one extra level
" too deep due to the extra tags we wrapped around the document.
" back to home
" restore the filetype
exe "set ft=" . l:origft
command! PrettyXML call DoPrettyXML()
Community content is available under CC-BY-SA unless otherwise noted.