对 VimL 脚本进行语法检查

发布于 2024-12-28 16:59:15 字数 152 浏览 1 评论 0原文

我有一个相当大的 vim 脚本(一个 .vim 文件,采用 viml 语法)。我想检查(但不执行!)该文件是否存在简单的语法错误。

我该如何实现这个目标?

我只想进行非常粗略的语法检查。类似于 perl -c 或 pyflakes 的东西。

I have a sizable vim script (a .vim file, in viml syntax). I'd like to check (but not execute!) the file for simple syntax errors.

How do I accomplish this?

I just want a very rough syntax check. Something along the lines of perl -c or pyflakes.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

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

评论(4

超可爱的懒熊 2025-01-04 16:59:15

我不认为(我尽可能确定)存在。 VimL 是 Vim 的内部语言(并且只有 Vim),为此开发的工具并不多。

我尝试在 vim.org 和其他几个地方搜索,但没有成功。这并不奇怪,因为我也从未听说过。

因此,您要么坚持运行脚本,要么切换到 Python、Perl 或 Ruby 等外部语言。

I don't think (I'm relatively sure, as much as one can be) one exists. VimL is an internal language of Vim (and only Vim), and there aren't many tools developed for it.

I tried searching on vim.org and several other places, with no luck. Not suprising, because I've never heard of one either.

So you're either stuck with running the script, or switching to an outside language like Python, Perl or Ruby.

2025-01-04 16:59:15

https://github.com/osyo-manga/vim-watchdogs

vim-watchdogs,显然是vim的语法检查器,它说它支持多种语言,包括vimL

如果你使用 vundle,你可以将其放入你的 vimrc 中:

Plugin 'git://github.com com/osyo-manga/vim-watchdogs.git'

..然后运行:

:PluginInstall

..进行设置(vundle 是一个非常漂亮的插件管理器)如果您有 syntastic,您可能需要小心并首先禁用它,并且然后看看它是否是一个足够的替代品(因为它说它无论如何都支持所有这些语言)。

可以肯定的是,当您有多个语法检查器运行时,您将需要“拴住狗”,可以这么说;通过配置一种语言来检查另一种语言不检查的语言,反之亦然。如果不这样做,最多只会出现冲突、重复或误导。在最坏的情况下,您将拥有以上所有内容以及更多。

确保你总是备份你的 ~/.vim 目录(或者你的 VIMRUNTIME 目录,如果你在全局级别上安装东西),你会很高兴你这样做了。希望对您或其他人有所帮助,祝您好运!抱歉,您等了 7.5 个月才得到回复,呵呵:)

https://github.com/osyo-manga/vim-watchdogs

vim-watchdogs, apparently, is a syntax checker for vim, it says that it supports many languages, including vimL

if you use vundle, you can just drop this into your vimrc:

Plugin 'git://github.com/osyo-manga/vim-watchdogs.git'

..and then run:

:PluginInstall

..to set it up (vundle is a very nifty plugin manager) If you have syntastic, you might want to be careful and disable it first, and then see if it is an adequate replacement (since it says it supports all those languages anyway).

It is a safe bet that when you have multiple syntax checkers going, you will need to put your "dogs on a leash", so to speak; by configuring one to check languages that the other one does not, and vice-versa. If you do not, there will be at best collisions, duplications, or misdirections. At worst, you will have all of the above and more.

Make sure that you always backup your ~/.vim directory (or your VIMRUNTIME directory if you install things on a global level), you will be glad you did. Hope that helped you or someone else out, good luck! Sorry you had to wait 7.5 months for a response, heh :)

椵侞 2025-01-04 16:59:15

现在有第二个选项: vim-lint (与 vimlint)

There's now a second option: vim-lint (as opposed to vimlint)

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