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?
Vi and Vim Stack Exchange is a question and answer site for people using the vi and Vim families of text editors. It only takes a minute to sign up.Sign up to join this community
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') finish endif let g:loaded_foo = 1
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
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 endif
If the plugin fails because of some patch that cannot be detected with
has(), you can use something like this:
if version < 704 || (version == 704 && !has("patch123")) let g:loaded_foo = 1 endif
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
Instead of having:
You can use:
if version < 704 || (version == 704 && !has("patch123")) Plug 'XXX/myPlug` endif
(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.
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') endif pathogen#infect()