I'm editing DocBook XML files and sometimes I need to format the using an external xmlformat
command. it is easy to run do this on the whole buffer of text, but how can i achieve the same only for a visually selected lines of text?
EDIT1: simply running !xmlformat
on selected lines works. the problem is that i need to do more things to the lines, such as get the number of indent of the first line, do the formatting, then shift the block to the indent size so that it aligns with the rest of the text.. It's summarized in https://github.com/tbazant/vim-daps/issues/38 BTW
EDIT2: the function in my plugin should be defined the way that it can handle either no input (run xmlformat on the whole file/buffer) or range of selected lines
!xmlformat
work? If not, maybe you could edit the question to explain why.:help v_!
:'<,'>!xmlformat
after a visual selection:'<
and'>
are marks which refer to the last visually selected text.!
directly from the visual selection will add both automatocally. (I know you know this already.)