I have some specific parts of files with unformated xml code. I need to write a vimscript function that selects the text and calls xmllint over it.
I know I can do this on the command line :'<,'>!xmllint --format -
But I really need to do the same in a vimscript function and I don't know how to make something like normal! call for visual.
I tried this but it does not work correctly :
function! MyFormat()
... stuff done here
let startl = line("'<")
let endl = line("'>")
let line = getline(startl, endl)
let r = system('echo "' . join(line, "") . '" | xmllint --format -')
call setline('.', r)
endfunction