vim tidy makeprg with stdin
Question
I've got this in .vim/ftplugin/html.vim:
set makeprg=%!tidy\ -q\ -i\ --show-warnings\ no
If I do make in a html file I get this error:
E499: Empty file name for '%' or '#', only works with ":p:h"
When I execute this:
:%!tidy -q -i --show-warnings no
It works beautifully. What am I doing wrong with my set makeprg?
Solution
I don't think makeprg
was intended to be used that way. I suggest you simply define your own mapping or command
:map ,m :%!tidy -q -i --show-warnings no<CR>
:Command Make %!tidy -q -i --show-warnings no<CR>
%!
replaces the contents of the buffer with the output of the following command, but when calling :make
, the %
is replaced with the file name for the current buffer. The error comes, because your current buffer is not editing a file, so the %
replacement can't take place.
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow