I'm trying to have a .vimrc that is portable between machines. Some computers I use have VimPlugin installed, while others don't. On the ones with VimPlug, I'd like to do some setup using
call plug#begin and
call plug#end. Currently though, I get an error on the computers without VimPlug, and on those, I'd just like to move on to the rest of the .vimrc.
Optimally, I'd want something like
if has('Vim-Plug') and just put the relevant code inside of that. It looks like some embed the installation of the manager right within their rc in an if statement, similarly to what I'd like to do:
if empty(glob('~/.vim/autoload/plug.vim')) silent !curl -fLo ~/.vim/autoload/plug.vim --create-dirs \ https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim endif
But this doesn't exactly work since vim still interprets the contents of the if statement, even if it doesn't execute it. I get an error:
E117: Unknown function: plug#begin even though that code is inside the if statement.
While researching this, I found tons of posts about checking if a particular plugin is installed, but none to check if the manager was installed. Is this not something I should be doing? Does anyone know a way to accomplish this? I'd rather not have to install Vim-Plug on every computer I use the rc on in order to keep it portable.