How to Install and Use Vim-Plug in Linux [Explained]

LINUX
FUNDAMENTALS
A Complete Guide for Beginners Enroll Course Now

To install Vim-Plug in Linux, follow the steps below:

  1. Download Vim-Plug using the curl or wget command.
  2. Open the .vimrc configuration file.
  3. Add Plug configuration to the .vimrc file.
  4. Save and Exit the .vimrc file.

To know each step in detail, go through this article. Here, I will show you how to install Vim-Plug in Linux and how to use it effectively.

What is Vim-Plug in Linux?

Vim-Plug in Linux is a plugin manager for the Vim text editor. It provides a minimalist and clean interface for managing, storing, installing, removing, and updating plugins. These plugins are a collection of vim script files that are organized in a specific directory structure.

What Are the Advantages and Drawbacks of Vim-Plug?

The Vim plugin manager is so simple that everyone should use it to customize and extend their editing environments. Here are some of the main advantages of it:

  • Simple Interface: Vim-Plug’s minimal and clean interface makes it popular among users.
  • Lazy Loading: To reduce startup time and memory consumption, it can load plugins only when required, not all at once.
  • Parallel Installation: Speed up the installation process by supporting parallel installation of plugins.
  • Customizability: It enhances functionality with its highly customizable potential.
  • Asynchronous Operations: This plug can execute two operations simultaneously such as installing and updating plugins at the same time.
  • Integration With Git: It allows users to manage plugins from the GitHub repository. It can also work with local plugins.
  • Community Support: It has a large active community of users and developers to provide support and share plugins.

Some drawbacks of the Vim-Plug are as follows:

  • Complexity: It enhances complexity while dealing with a large number of plugins.
  • Dependency: Dependency on external sources such as GitHub reduces its capabilities.
  • Compatibility Issues: There may arise compatibility issues between Vim-Plug and certain versions of Vim and plugins.

How to Install Vim-Plug in Linux?

To install Vim-Plug properly, follow each step cautiously:

Step 1: Download Vim-Plug Plugin Manager

To download the Vim-Plug plugin manager script using the curl command, copy the following command:

curl -fLo ~/.vim/autoload/plug.vim --create-dirs \
https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim
EXPLANATION

Here, the curl command will download the vim-plug and store it in the ~/.vim/autoload/plug.vim directory. If this directory does not exist, the --create-dirs flag will create it. Then the following URL downloads the Vim script file from GitHub.

download vim-plug

Note: If “curl” is not installed in your system, install it with this command:

sudo apt install curl

You can also download this plug using the wget command:

wget -O ~/.vim/autoload/plug.vim \
https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim

Step 2: Open Vim Configuration File

Open the .vimrc configuration file with this command:

vim ~/.vimrc

If this configuration file does not exist in your Linux system, create this file in your home directory using the vim .vimrc command.

Step 3: Add Vim-Plug Configuration

Add Vim-Plug configuration by writing the following lines to the .vimrc configuration file:

" Specify the directory for Vim-Plug to manage plugins
call plug#begin('~/.vim/plugged')

" List your plugins here

" End Vim-Plug section
call plug#end()
EXPLANATION

Here, the call plug#begin(...) and call plug#end() mark the starting and ending of the Vim-Plug configuration section in the .vimrc file. '~/.vim/plugged' is the directory where Vim-Plug will manage the provided plugins. If this directory does not exist, Vim-Plug will create it.

configure vim-plug

Note: Vim-Plug depends on Github repositories to install or update plugins, make sure that you have Git installed in your system. If not, install it with this command:

sudo apt install git

Step 4: Save and Exit

Once you have added the Plug configuration, save and exit the .vimrc file using :wq or :x command:

save and exit vim-plug configuration

The installation procedure is complete.

To learn how to use Vim-Plug, read the following article:

How to Use Vim-Plug?

This dedicated plug is used to manage plugins like installing, updating, removing, etc. In this section, I will describe how to use it efficiently.

A. Install Plugins

To install plugins using Vim-Plug, follow the instructions below:

  1. Open the .vimrc file using Vim.
  2. Add the desired plugin to the .vimrc file to install. In this case, I will install the NERDTree plugin by adding the following line in the Vim configuration file:
    Plug 'preservim/nerdtree'

    installing vim plugin
    You can also install multiple plugins by adding more plugins in the Vim script file.

  3. Save the changes made to the file and exit it by writing :wq command from the normal mode.
  4. Restart Vim, write this command to install the specified plugin, and press ENTER:
    :PlugInstall

    installing vim nerdtree plugin
    As you can see the NERDTree Vim plugin has been installed on your system. You can open this plugin using :NERDTreeToggle command. This plugin will toggle NERDTree file explorer, allowing you to navigate files and projects with ease.

Note: Press q to quit the NERDTree window.

B. Update Plugins

To update plugins, open the .vimrc file and write the following command:

:PlugUpdate

update vim nerdtree plugin

After writing the command, press ENTER to update the plugin specified in the Vim config file.

C. Remove Plugins

You can also remove added plugins with the Vim plugin manager. Let’s see how to remove the NERDTee plugin. To do so, follow the steps below:

  1. Open the Vim config file with Vim.
  2. Switch to insert mode from normal mode pressing i key.
  3. Comment out the plug with (") quote:
    remove vim nerdtree plugin
  4. Save and exit the file with :wq command.
  5. Now, execute :PlugClean command to remove directories that are no longer listed in your .vimrc file:
    remove vim nerdtree plugin2
  6. After writing ‘y’, press ENTER to complete the removal process:
    clean vim nerdtree plugin using Vim-Plug

Conclusion

In conclusion, I have described what Vim-Plug is and what are its benefits and drawbacks. I have also shown you how to install and how to use it to install, update, and remove plugins. Please let me know if you experience any problems while installing this Plug!

People Also Ask

Where is Vim plugin?

Vim plugins are installed in the ~/.vim directory by default. You will find all the Vim plugins there.

How do I install Vim-plugin in Linux?

To install Vim-Plugin in Linux, add the GitHub repository URL of the plugin you want to install to the .vimrc file. Then save and exit the file using :wq command. After that, restart Vim, execute :PlugInstall command, and press ENTER to install the intended Vim plugin.

How do I restore plugins in Vim?

To restore plugins in Vim, clean the .vim directory using :PlugClean command. Then reinstall the plugins by adding the plugin to the Vim script file and execute :PlugInstall command.

How to remove installed plugins in Vim?

To remove installed plugins in Vim, open the .vimrc file and comment out the plugin line with ("). For instance, to remove nerdtree plugin, place “ before "Plug 'preservim/nerdtree'.

Related Articles


<< Go Back to Vim in LinuxLinux Text Editors | Learn Linux Basics

Rate this post
Mitu Akter Mou

Hello, This is Mitu Akter Mou, currently working as a Linux Content Developer Executive at SOFTEKO for the Linuxsimply project. I hold a bachelor's degree in Biomedical Engineering from Khulna University of Engineering & Technology (KUET). Experiencing new stuff and gathering insights from them seems very happening to me. My goal here is to simplify the life of Linux users by making creative articles, blogs, and video content for all of them. Read Full Bio

Leave a Comment