2

I wonder what the best way is to decide whether or not some plugin should be loaded depending on some specific compilation/version of Vim. Any help would be appreciated.

3

If you want it to depend on the version, use this:

if version > 700
    "do stuff for version 7 and up
endif

If what you really want to know is whether a certain command works, you can use the exists statement:

if exists('+breakindent')
    set breakindent
endif

If it's being in a GUI that you care about, try if has('gui_running') or put the commands into .gvimrc.

| improve this answer | |
  • Thanks. In particular, I would like to load a plugin if I happen to run in gVim or Macvim, but not otherwise. Maybe this implies that it's not the version I'm really looking for? – gustafbstrom Feb 8 '16 at 13:21
  • @gustafbstrom You can add stuff that's specific to gvim into .gvimrc. I don't know about macvim. – klimpergeist Feb 8 '16 at 13:23
  • 2
    @gustafbstrom I just realized: You probably want to react to the gui. Try if has('gui_running'). – klimpergeist Feb 8 '16 at 13:25

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.