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

352 views Asked by At

I've been using Vim for a while but still get confused by configuration. I want to config my Vim in such a way that YCM (YouCompleteMe, an auto-complete plugin) only gets loaded if running in GUI mode (e.g. MacVim), while if terminal Vim (maybe misnomer, I mean text-based Vim launched from command line) runs, YCM won't be loaded.

This question actually can be generalized to "How to selectively load plugins depending on running mode?". I though it must has been considered elsewhere, but Google gets me little useful information.

2

There are 2 answers

3
VanLaser On BEST ANSWER
if has("gui_running")
    ... enable gui stuff here
else
    ... enable terminal stuff here
endif

(see h: feature-list)

0
Lithis On

Put your GUI-only configuration in the file .gvimrc.

Console Vim sources .vimrc when it starts. GUI Vim sources .vimrc and then .gvimrc, so settings in .gvimrc can override settings in .vimrc. For more information, see :help gui-start.