vim 使用 stdin 整理 makeprg

发布于 2024-12-15 12:20:26 字数 346 浏览 5 评论 0原文

我在 .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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

半边脸i 2024-12-22 12:20:27

我不认为 makeprg 打算以这种方式使用。我建议您简单地定义自己的映射或命令

:map ,m :%!tidy -q -i --show-warnings no<CR>
:Command Make %!tidy -q -i --show-warnings no<CR>

%! 将缓冲区的内容替换为以下命令的输出,但是当调用 :make 时,% 替换为当前缓冲区的文件名。错误出现,因为您当前的缓冲区没有编辑文件,所以 % 替换无法进行。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文