This post is about how to write some vim-script to autoload the plugin manager from the .vimrc. This makes the process of getting up and running on a new system easier because the plugin manager is automatically downloaded as well as the plugins are also automatically downloaded.

Using the commands from https://github.com/junegunn/vim-plug I was able to create a script to auto download VimPlug for vim and NeoVim on windows and on Linux.

" Expand the home directory to an absolute path.
let homeDir = expand('~')

" Find the desired VimPlug install location for different system configurations.
if(has('win32') || has('win64'))
if has('nvim')
let shareDir=homeDir.'\AppData\Local\nvim'
else
let shareDir=homeDir.'\vimfiles'
endif
else
if has('nvim')
let shareDir=homeDir.'/.local/share/nvim/site'
else
let shareDir=homeDir.'/.vim'
endif
endif

" Url of the VimPlug script.
let plugUri = 'https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim'
if empty(glob(expand(plugVim)))
if has('win32') || has('win64')
" Make sure the autoload directory has been created.