lady installing vim plugis on pc

How to Install a Plugin In Vim

Vim is a versatile, powerful, and lightweight command-line text editor that has proven to be indispensable over time.

You can install Vim on Windows, macOS, Unix, and Linux. Actually, most Unix and Linux-based systems come with Vim by default. One of the best ways to extend Vim’s functionality is via plugins, and here’s how you can install plugins in Vim.

Why Install Vim Plugins?

Vim is a feature-packed editor; it is also modular and highly customizable. If the Vim editor doesn’t come with a certain function or feature that you are looking for, chances are you can probably find a plugin for it or at the worst build a plugin yourself. Often, there is already a plugin that exists for the functionality you are looking for.

Plugins are one of the most-loved features of Vim because they allow you to extend Vim’s functionality while keeping the size of the core program lean and relevant. The concept of plugins or extensions is emulated in most graphical editors such as Visual Studio Code (VS Code), Atom, etc.

Vim Plugin Installation Methods

There are two main methods of installing plugins in Vim. The first method is to install a plugin manually by copying the plugin content to a designated folder. The other, and the most common method is to install plugins via a plugin manager.

Let’s take a look at both methods so you can choose which one best meets your needs. Also, it is important to note there are several plugin managers that you can use.

You’ll need to install Git on your PC for both plugin installation methods.

1. Installing a Plugin Manually

Starting with Vim version 8, you can install plugins without the need for a package manager by using the default package management tool.

You can place Vim plugins in the ~/.vim/pack/vendor/start/plugin_name directory. Note that the plugin_name folder name will vary from plugin to plugin. To demonstrate this point, let’s install a Vim plugin known as NERDTree. It is a widely used file system explorer for Vim. NERDTree allows you to visualize a project folder structure in a tree view.

First, change your directory to the home directory using the following command:

cd ~

Then look for the .vim folder with the command ls -al, to show hidden files and folders. Navigate to the folder if it exists.

If you do not have the .vim folder in your home directory, create the folder structure for the NERDTree plugin that we want to install using the command below:

mkdir -p .vim/pack/vendor/start/nerd_tree

Vim recommends that you create a separate folder for each plugin for easy management. So, if you are to install another plugin, you will create a new folder for the plugin in the ~/.vim/pack/vendor/start/ directory.

Next, download the NERDTree plugin from GitHub and place it in the nerd_tree plugin directory using the following command:

git clone https:

Most plugin pages will contain instructions on how to download a plugin from its source.

Start the Vim editor and then type the command :NERDTree to open the NERDTree file explorer. Here is an ASP.NET Core web API project opened in Vim using NERDTree.

To uninstall a plugin, simply delete its corresponding plugin folder (in this case, nerd_tree).

2. Installing Vim Plugins With a Plugin Manager

Package managers have been the traditional way of installing plugins in Vim, prior to Vim version 8. They are supported in all versions of Vim and there are several package managers that you can use to install plugins.

Some of the most notable plugin managers include Vundle, VAM, vim-plug, pathogen, etc.

The advantage of plugin managers is that you are not involved in creating the folder structure manually, and it is easier to update packages automatically.

Let’s install a plugin via vim-plug. It is widely used in the Vim community, so it has great community support and is also well documented.

First, install vim-plug using the command:

curl -fLo ~/.vim/autoload/plug.vim --create-dirs https:

Next, create an entry for your plugin in the ~/.vimrc file. If you don’t have the ~/.vimrc file, you can create it using the touch ~/.vimrc command.

Enter the following text in your ~/.vimrc file.

call plug
Plug 'preservevim/NERDTree'
call plug

All plugins that you intend to install should be placed within the line call plug#begin() and call plug#end(). In this case, we want to install NERDTree. After adding the plugin names, save the file.

Open your Vim editor and run the command :PlugInstall to install the plugin. Restart Vim for your changes to take effect.​​

Customizing the Vim Editor on Linux

We’ve looked at how to customize and extend Vim’s functionality by installing plugins. The ~/.vimrc file is the best place to add custom Vim configurations if you want to make the editor look good.

Original Link

Leave a Comment

Your email address will not be published.

Scroll to Top