VIM Plug – Is it the Best VIM Plugin Manager?

Highlights

  • Vim, one of the fastest text editors, lags in terms of not having a feature to manage plugins.
  • Here’s why it lets you use plugin managers for the purpose, and Vim Plug is one such kind.
  • So, if you want to know what it is, how to install and use it, we have mentioned it all.
Advertisement
Vim Plug
TechLatest is supported by readers. We may earn a commission for purchases using our links. Learn more.

Vim is one of the easiest and most robust text editors, especially for the tech-savvy. Further, to master it, you only need to be familiar with some commands and hence, not much complexity.

Advertisement

But you would feel there are not many features in it. Well, Vim was developed to be fundamental in functionality and can be customized flexibly as per needs.

To do so, you need the Vim plugin. There is no standardized way for installing Vim plugins, like a plugin store or something.

Therefore, you have to install another plugin like Vim plug via the terminal. It is an all-in-one plugin manager, and whether you are wondering what it is, why it is required how to use it, we have covered you all! 

What is Vim Plug?

It is a free and open-source project meaning that you can access its source code, modify it, and redistribute it legally. Besides, similar to the Vim text editor, the plugin is minimal in function and software weight. 

Thus, it’s fast and can install/update multiple plugins simultaneously. Unlike most other plugins, you can roll back (undo) the updates. 

It’s noteworthy that it creates shallow clones of the plugins. This means that Vim Plug makes a copy of the remote repository, which is not detailed and has lesser commits yet can perform the same function. By using these copies on your system, Vim Plug Manager plugins faster than others and consumes lesser disk space. 

Besides, it loads plugins as and when required, which leads to a lower startup time. 


What is the Need for Vim Plug?

Vim is a powerful Unix text editor quite popular due to its lightweight, modal editing, customizability, speed, and efficiency. Though it’s of small size and supports basic edits, you can add plugins to edit to extend functionality, and one such is the Vim plugin. 

Advertisement

However, this text editor did have a drawback earlier. There’s no plugin manager in it, so if you want to add a plugin, you must download, distribute and extract them in a specific directory ~/.vim.

Only tech savvy could do it, and novices did find it problematic. Further, even those familiar with the process found it not worth devoting time and effort to plugin management. 

Another significant and apparent issue was that all the installed plugins were in a single ~/.vim directory. Thus organization, management, and overseeing each of them became a hassle. Besides, these plugins did contain files, and users cannot figure out which file to remove for uninstalling.

Here’s where Vim Plug came into the picture. It is one of the most popular plugin managers and standardized plugin managers for Vim. It stores files of all the plugins in separate directories and keeps them well organized. 

Advertisement

If you want to learn more about the VIM Plug, do visit its GitHub Repository.


What to Do Before Installing Vim Plug?

As mentioned earlier, Vim Plug creates a copy of the repository. Similarly, Vim has repositories over GitHub and GitLab, which need to be cloned before usage. To do so, you must have Git and Curl. 

Here’s how you can create source clones of Vim for different systems: 

# For Debian Based distributions like Ubuntu
sudo apt install git
 
# For Fedora or RPM-based system
sudo dnf install git
 
# For Arch-based distributions
sudo pacman -S git
sudo apt install git

How to Install Vim Plug?

After knowing the need for Vim Plugin detail, you should get the incredible manager soon. 

Advertisement

To install it, you have to open the terminal and enter the following command in it: 

In case you are getting a “curl not found” error, that means you will have to install curl first. Use the following command to do so-

sudo apt install curl
curl -fLo ~/.vim/autoload/plug.vim --create-dirs \
    https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim
Install Vim Plug
Install Vim Plug

It downloads the plugin manager and even installs it with the specific command. In it, –the create-dirs part creates the important directories it needs to download files. Thus, the autoload directory isn’t there in  /.vim/, but at Plug.vim; here’s where the plugin’s location would be. 

The URL refers to the Plug link, and this part of the command points to the location of Plug.vim. Thus, the command indicates curl to download the plugin from the given URL, which will further save it as an autoload directory “/.vim/autoload/ directory” as ‘plug.vim

Moving ahead, your next step would be to choose which plugins you need, and deciding it is sometimes challenging. 

Advertisement

How to Choose Plugins To Download via Vim Plug?

To extend the functionality of your Vim text editor’s functionality, you have plenty of choices. Amongst them, choosing the preferred one for your purpose is challenging.

They are minimalistic and hence are designated for a specific feature. Another noteworthy thing is ensuring that the plugins you choose to install are appropriately maintained. 

There are a lot of plugins available for each feature/problem that you can imagine, but choosing which exact plugins from the set of plugins that provide similar features can be an uphill task.

The below-mentioned are some of the best ones available-

Advertisement

Edit the Vimrc

Before Installing any plugin with Vim Plug, you must edit the Vimrc. It is the configuration file for the editor, and it loads its process every time you launch it. This is again of two types: global config present in $VIM, which you shouldn’t change manually, and local config file, which you can change if required. The latter isn’t always present by default; therefore, you must create it before editing Vimrc. 

The first step is to create a .vimrc file by using the command given below:

touch ~/.vimrc

Next, open the file to modify 

vim ~/.vimrc

You need to follow the next steps for installing a plugin:

Advertisement

Afterward comes the process of installing the plugin, for which you must use the command Plug<Link to Plugin Repository>. Using this method, you have already downloaded Vim Plug. Further, if the plugin is in the GitHub repository, you can mention Plug<Username><Repository>

Now, you have to install plugins via Vim Plug. You must enclose them between the keywords plug#begin() and plug#end(). 

Thus, your Vimrc would be something like 

call plug#begin()
 
Plug 'tyru/open-browser.vim' " opens url in browser
Plug 'http://github.com/tpope/vim-surround' " Surrounding ysw)
Plug 'https://github.com/preservim/nerdtree', { 'on': 'NERDTreeToggle' }
Plug 'https://github.com/ap/vim-css-color' " CSS Color Preview
Plug 'https://github.com/tpope/vim-commentary' " For Commenting gcc & gc
 
call plug#end()

After installing plugins via Vim, you should look at some other aspects. 

Advertisement
VIM Plug installer

Update Plugins

Vim Plug is an excellent plugin manager, so updating them without a hassle is also a chore for Vim Plug. To update plugins, you have to execute the command :PlugUpdate. Further, press d on your keyboard to analyze the changes when you update. Apart from that, you can even enter :PlugDiff to do so. 


Review Plugins

Updating plugins for Vim is not always a good idea. This is because sometimes it invites bugs, or they no longer function efficiently. In such a scenario, you can roll back the updates. 

To do so, execute :PlugDiff command and review the changes after the update. Now, roll back every plugin to install a consistent state from :PlugUpdate. For it, you have to type X in each paragraph. 


Removing Plugins

If you want to remove a plugin, all you have to do is delete or remove the comment of the plugin commands you added in the Vim config file. Next, restart the editor. Now, run the command to proceed with uninstallation- :PlugClean.

Advertisement

It will delete all the undeclared plugins. Since you had removed the comments and commands of the plugins you wanted to remove, they also come under the undeclared category.


Frequently Asked Questions

What is a Vim plug?

Vim Plug is a lightweight plugin manager for Vim text editors. It is unique as it has one of the fastest parallel installers.

Why is Vim better than Notepad?

Vim’s speed is quite more than that of Notepad++.

Do software engineers use Vim?

Yes, software engineers do use Vim.


The Final Word – VIM Plug

If you were looking for an incredible plugin manager for Vim text editor and wanted to know about Vim Plug, you would have got your answer. Not only is it powerful, but also effective in functionality. 

For the first time, you would find it troublesome to install Vim Plug and how to use it for desired purposes in Linux, but the guide is simplified. All you need to do is follow it carefully to avoid discrepancies and failure in doing the expected.

Further Reading:

Advertisement
Leave a Comment
Subscribe
Notify of
guest
2 Comments
Newest
Oldest Most Voted
Inline Feedbacks
View all comments
Advertisement