I'm trying to reindent current HTML file with this command from inside vim :
:!xmllint --html --format % 2>/dev/null
But, all it does it displays the output to stdout without actually modifying the file.
EDIT0 : I just found this but I'm not sure if this the correct way to do this :
:%!xmllint --html --format - 2>/dev/null
:%
stands for the vim range :1,$
(the entire file) and -
tells xmllint
to read data from stdin
EDIT1 : @statox, Finally, I'll be using equalprg
:
autocmd FileType html let &l:equalprg='xmllint --html --format --recover - 2>/dev/null' "Pretty print HTML when 'gg=G' is pressed
Here's some vim help about the let &
syntax:
:h let-& :let &{option-name} = {expr1} :let-option :let-& Set option {option-name} to the result of the expression {expr1}. A String or Number value is always converted to the type of the option. For an option local to a window or buffer the effect is just like using the :set command: both the local value and the global value are changed. Example: :let &path = &path . ',/usr/local/include' This also works for terminal codes in the form t_xx. But only for alphanumerical names. Example: :let &t_k1 = "\<Esc>[234;" When the code does not exist yet it will be created as a terminal key code, there is no error. ... :let &l:{option-name} = {expr1} :let &l:{option-name} .= {expr1} :let &l:{option-name} += {expr1} :let &l:{option-name} -= {expr1} Like above, but only set the local value of an option (if there is one). Works like :setlocal. :let &g:{option-name} = {expr1} :let &g:{option-name} .= {expr1} :let &g:{option-name} += {expr1} :let &g:{option-name} -= {expr1} Like above, but only set the global value of an option (if there is one). Works like :setglobal.
:h 'equalprg'
but you can check the different answers to this question which should give you the information you need.setlocal equalprg
bylet &l:equalprg