3

I have powerline installed on some of my computers, but not on others. I'd like my .vimrc to detect if it is installed before trying to load/enable the powerline package so I can avoid the errors that are generated.

How can I detect if powerline is installed?

I should note that I use Vundle as my Vim package manager.

jlconlin
  • 14,206
  • 22
  • 72
  • 105

1 Answers1

2

I do not use powerline, but this is the generic method.

Assuming you using Vim's packages you move your extra plugins to be optional packages and then just use :silent! when doing :packadd in your vimrc.

silent! packadd other_plugin

Alternatively you can use exists() & VimEnter autocmd if you need something more complex.

augroup load_more
  autocmd!
  autocmd VimEnter * if exists(':SomeCommand') | packadd foo | endif
augroup END

NOTE: I do not use powerline so I do not know what commands or variables are provided to use. It could provide a custom autocmd event to simplify this or have some other method for loading related plugins.

For more help see:

:h exists()
:h VimEnter
:h :silent
:h packages
Peter Rincker
  • 43,539
  • 9
  • 74
  • 101
  • I should have added to my question that I use Vundle as my package manager. I've updated the question. – jlconlin Nov 26 '19 at 19:42