为什么没有VIM插件在Ubuntu 20.04上工作?

发布于 2025-02-09 13:22:12 字数 943 浏览 1 评论 0原文

我正在VMBox上运行Ubuntu 20.04,并试图从VIM中获得最大收益。所以我遵循本指南 https ://techinscribed.com/how-to-set-up-im-vim-as-in--for-react-and-typescript-in-2020/ 要安装不同的插件,从Gruvbox开始。不幸的是,即使我遵循了这封信的指南,gruvbox和任何其他插件都没有工作。 因此,这是我的主文件夹中的.vimrc文件:

call plug#begin()
" This is where we will add plugins to install

Plug 'morhetz/gruvbox'

call plug#end()

colorscheme gruvbox

这是错误消息:

Error detected while processing /home/marcel/.vim/plugged/gruvbox/colors/gruvbox.vim:
line    8:
E492: Not an editor command: ^M
line   11:
E492: Not an editor command: ^M
line   12:
E15: Invalid expression: version > 580^M
line 1419:
E171: Missing :endif
Press ENTER or type command to continue

其他任何插件都会发生类似的错误...我已经尝试了另一种配色方案和Nerdtree。这是一个已知问题吗?我如何减轻问题?

I'm running Ubuntu 20.04 on VMBox and am trying to get the most out of Vim. So I as following this guide
https://techinscribed.com/how-to-set-up-vim-as-an-ide-for-react-and-typescript-in-2020/
to install different plugins, starting with gruvbox. Unfortunately, neither gruvbox nor any other plugins worked, even though I followed the guide to the letter.
So here's my .vimrc file in my home folder:

call plug#begin()
" This is where we will add plugins to install

Plug 'morhetz/gruvbox'

call plug#end()

colorscheme gruvbox

And here are the error messages:

Error detected while processing /home/marcel/.vim/plugged/gruvbox/colors/gruvbox.vim:
line    8:
E492: Not an editor command: ^M
line   11:
E492: Not an editor command: ^M
line   12:
E15: Invalid expression: version > 580^M
line 1419:
E171: Missing :endif
Press ENTER or type command to continue

Similar errors happen with any other plugin... I already tried a different color scheme and also the NERDtree. Is this a known issue? How can I alleviate the problem?

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

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

发布评论

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

评论(2

回眸一笑 2025-02-16 13:22:12

虽然VIM可以完美地编辑使用Windows行结尾(\ r \ n,请参见其他答案),但它对其运行时文件很挑剔,该文件必须必须具有UNIX行结尾(\ n)。

因此,问题在于,您通过插件管理器获得的运行时文件具有Windows行末尾,而不是预期的UNIX线路结尾。

现在,您的插件管理器使用git检索这些运行时文件,这是最有可能更改行结尾的地方。如果是这样,此处是在GIT中配置线路结尾的指南。

While Vim can perfectly edit files with Windows line endings (\r\n, see the other answer), it is picky about its runtime files which must have Unix line endings (\n).

The problem, here, is thus that the runtime files you get via your plugin manager have Windows line endings instead of the expected Unix line endings.

Now, your plugin manager uses Git to retrieve those runtime files and that is where the line endings are most likely to be changed. If that's the case, here is a guide for configuring line endings in Git.

余生再见 2025-02-16 13:22:12

在我看来,这只是线结尾的问题。 Unix使用\ n(或0xa)用于newline字符。 Windows使用两个字符的组合:\ r \ n\ r的十六进制是0xd^m恰好是VIM显示的方式0xd0x0d = 13,m是英语字母中的第13个字母)。

您可以通过运行以下内容来删除所有 ^m字符:

:%s/ ^m // g

在将其执行到gruvbox.vim之后,我敢打赌,错误会消失。

It looks to me like it's just an issue with the line endings. Unix uses \n (or 0xA) for a newline character. Windows uses a combination of two characters: \r \n. The hex for a \r is 0xD. ^M happens to be the way vim displays 0xD (0x0D = 13, M is the 13th letter in the English alphabet).

You can remove all the ^M characters by running the following:

:%s/^M//g

Once you do that to your gruvbox.vim, I would bet that the error goes away.

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