E518:未知选项:#

inv*_*d0r 6 vi vim

我将vimconfig中的默认设置复制到新创建的 .vimrc 中。启动 vim 后,会出现一堆以下消息:

E518: Unknown option: #
Run Code Online (Sandbox Code Playgroud)

阅读vim e518: 未知选项:我假设它与 modeline 有关:

“[...] 行的格式被 Vim 识别为模型行,如错误消息中所述。模型行允许在文件中设置选项” - jamessan

我不太明白所提供的信息:help modeline

我是否需要添加一行:

vi:noai:sw=3 ts=6 
vim: tw=77
Run Code Online (Sandbox Code Playgroud)

因为set: nomodeline重启vim后没有效果

如何让 vim 忽略 .vimrc 中的注释?

Knu*_*nut 7

您的注释.vimrc以双引号 ( ) 开头"

例子:

"
" using the mouse
"

" mouse - list of flags for using the mouse
set mouse=n

" mousemodel - "extend", "popup" or "popup_setpos"; what the right mouse button is used for
set mousem=extend
Run Code Online (Sandbox Code Playgroud)

  • 那个网站确实很奇怪。无论如何,你可以使用 `:%s/#\{1,}/"` 将所有 `#` 替换为 `"` (8认同)
  • 我刚刚给作者发了一封电子邮件,要求他更换评论领导者。 (4认同)