如何仅针对 MacVim 启用 YCM(同时对终端 Vim 禁用它)

How to enable YCM for MacVim only (while keep it disabled for terminal Vim)

我已经使用 Vim 一段时间了,但仍然对配置感到困惑。我想以这样的方式配置我的 Vim,如果 运行 在 GUI模式(例如MacVim),而if 终端Vim(可能用词不当,我的意思是基于文本的Vim启动从命令行)运行,YCM 不会被加载。

这个问题其实可以推广到"How to selectively load plugins depending on running mode?"。我虽然在其他地方肯定已经考虑过它,但是 Google 给我的有用信息很少。

if has("gui_running")
    ... enable gui stuff here
else
    ... enable terminal stuff here
endif

(见h: feature-list

将您的 GUI-only 配置放在文件 .gvimrc 中。

控制台 Vim 启动时获取 .vimrc。 GUI Vim 来源 .vimrc 然后 .gvimrc,因此 .gvimrc 中的设置可以覆盖 .vimrc 中的设置。有关详细信息,请参阅 :help gui-start