Most Linux distribution is now preinstalled with VIM 8+ version. Vim 8 has built support for packages. You can now easily install Vim plugins with this added support.
Package support helps to add, update, remove and manage packages. Vim can natively load third-party packages without the help of any plugin manager.
In this tutorial, you learn how to install Vim plugins manually and using a plugin manager.
Install Vim plugins
Let's check how to install Vim plugins manually, this is recommended method for Vim 8+
By default, Vim expects each plugin to be stored in the ~/.vim/pack/<my-plugins>/. When Vim starts, it will load all plugins stored in /.vim/pack/my-plugins/start. You can give any name for the directory
Create the directory to store Vim plugins:
$ mkdir -p ~/.vim/pack/my-plugins/start
If you don't want the Vim plugin to start automatically at the start, create a subfolder
opt under the plugin directory ( here '
my-plugins') and add package there.
The package added in opt can be loaded to memory by:
$ mkdir -p ~/.vim/pack/my-plugins/start/NERDTree/ $ git clone --depth 1 https://github.com/preservim/nerdtree.git ~/.vim/pack/my-plugins/start/NERDTree/
$ mkdir -p ~/.vim/pack/my-plugins/start/Airline/ $ git clone --depth 1 https://github.com/vim-airline/vim-airline.git ~/.vim/pack/my-plugins/start/Airline/
Install Vim plugin using a plugin manager
Plugin Managers is still useful because of its features. Plugin manager has features such as updating, disabling plugins make it easy to manage vim plugins.
Popular plugin managers are Vim-plug, Vundle, Pathogen, dein.vim, and VAM.
Let's check how to install vim plugins using vim-plug.
Step 1: Install the vim-plug
$ curl -fLo ~/.vim/autoload/plug.vim --create-dirs https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim
Step 2: Create ~/.vimrc file
$ touch ~/.vimrc file
Step 3: Add plugins to install in ~/.vimrc file
Add the name and location of each plugin to be installed between the plug#begin and plug#end() lines.
call plug#begin() Plug 'preservim/NERDTree' Plug 'vim-airline/vim-airline' Plug 'https://github.com/ap/vim-css-color' call plug#end()
Step 4: Install Plugins
Open Vim on your terminal and type:
To update a single plugin, type:
In this tutorial, we learned how to install Vim Plugins manually and using a plugin manager.
If you have any feedback and suggestion please comment below.