vim 使用 stdin 整理 makeprg
我在 .vim/ftplugin/html.vim 中有这个:
set makeprg=%!tidy\ -q\ -i\ --show-warnings\ no
如果我在 html 文件中 make,我会收到此错误:
E499: Empty file name for '%' or '#', only works with ":p:h"
当我执行此操作时:
:%!tidy -q -i --show-warnings no
它工作得很好。我的 makeprg 集做错了什么?
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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我不认为
makeprg
打算以这种方式使用。我建议您简单地定义自己的映射或命令%!
将缓冲区的内容替换为以下命令的输出,但是当调用:make
时,%
替换为当前缓冲区的文件名。错误出现,因为您当前的缓冲区没有编辑文件,所以%
替换无法进行。I don't think
makeprg
was intended to be used that way. I suggest you simply define your own mapping or command%!
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.