FUNDAMENTALS A Complete Guide for Beginners
To install Vim-Plug in Linux, follow the steps below:
- Download Vim-Plug using the curl or wget command.
- Open the .vimrc configuration file.
- Add Plug configuration to the .vimrc file.
- 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
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.
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()
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.
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:
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:
- Open the .vimrc file using Vim.
- 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'
You can also install multiple plugins by adding more plugins in the Vim script file. - Save the changes made to the file and exit it by writing
:wq
command from the normal mode. - Restart Vim, write this command to install the specified plugin, and press ENTER:
:PlugInstall
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
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:
- Open the Vim config file with Vim.
- Switch to insert mode from normal mode pressing
i
key. - Comment out the plug with
(")
quote:
- Save and exit the file with
:wq
command. - Now, execute
:PlugClean
command to remove directories that are no longer listed in your .vimrc file:
- After writing ‘y’, press ENTER to complete the removal process:
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
- How to Install Vim in Ubuntu? [5 Methods]
- How to Edit With Vim in Linux? [Explained]
- How to Set Vim Color Scheme in Linux? [4 Steps]
<< Go Back to Vim in Linux | Linux Text Editors | Learn Linux Basics