I have a couple of plugins that don't work correctly on some machines running earlier versions of Vim.

Is there a way to supress the Error detected while processing... errors when I start up vim in these environments?


It depends on the plugin and on what is causing the error. Most plugins have a block of code near the top of the plugin that looks like this:

if exists('g:loaded_foo')
let g:loaded_foo = 1

where foo is usually the name of the plugin. This prevents the plugin from being loaded more than once, but also allows the user to prevent it from being loaded at all by setting g:loaded_foo in their ~/.vimrc.

If your problematic plugin has such a block, then you can put code like the following in your ~/.vimrc. If the plugin fails because it is using a function such as and() that exists only in recent versions of Vim, you can use something like this:

if !exists("*and")
    let g:loaded_foo = 1


:help exists()

If the plugin fails because of some patch that cannot be detected with exists() or has(), you can use something like this:

if version < 704 || (version == 704 && !has("patch123"))
    let g:loaded_foo = 1
| improve this answer | |
  • Thanks for your solution. I was looking for an easy do-it-all setting that would somehow disable all the errors. I guess it doesn't exist. What I ended up using was a combinations of if statement checks and pathogen's g:pathogen_disabled variable. – Shawn Conn Aug 12 '15 at 4:46

I'll base my answer on GaryJohn's one. The idea is the same: creating conditions on your Vim version or on features that you need.

Using global varibales like g:loaded_foo may be a problem on some plugin which do not provides this kind of variables. If you use a plugin manager you could instead use the following line in your if condition:

Plug 'XXX/myplug'` 

Instead of having:

Plug 'XXX/myPlug`

You can use:

if version < 704 || (version == 704 && !has("patch123"))
    Plug 'XXX/myPlug`

(Or whatever condition as GaryJohn stated)

This prevent vim from loading the plugin event if it is poorly designed and doesn't provides a global variable.

NOTE 1 Of course the plugin manager need to have these lines between its beginning and ending lines (like call plug#begin('~/.vim/plugged') and call plug#end()for Vim-plug).

NOTE 2 My example use the Vim-plug syntax because I tried it with this plugin manager but I see no reason why it wouldn't work with other plugin managers.

NOTE 3 As I'm writing this answer I'm remembering that Vim-Plug as a "on demand loading" which might be tricked to load plugins depending on the Vim version. I'm not sure of this point btw.

| improve this answer | |
  • Thanks for your solution. I'm not using vim-plug unfortunately. I was able to find a pathogen-centric solution however. – Shawn Conn Aug 12 '15 at 4:47
  • You're welcome! If your solution differs from the already existing answers don't hesitate to answer your own question it might be useful to other users :-) – statox Aug 12 '15 at 4:54
  • 1
    One step ahead of you :) – Shawn Conn Aug 12 '15 at 4:58

If you happen to have pathogen, another solution here is to use its g:pathogen_disabled array variable. In your .vimrc you can add bundle names to this array based on vim's reported environment. Upon calling call pathogen#infect(), it will not enable the listed plugins.

"Airline only works on Vim 7.2+
let g:pathogen_disabled = []
if v:version < 702
  call add(g:pathogen_disabled, 'vimproc')
| improve this answer | |

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.