Vim Install Plugins

29/12/2020
Ever heard the name of Vim? I bet you did! It’s one hell of a text editor. In fact, Vi/Vim is one of the longest-living applications of all times. It’s more than 20 years old and still going strong! Despite having a low usage rate, Vim is one of the finest text editors one can ever have. It’s mature, stable and expandable with all the powerful plugins available all over the internet.

With stable and robust plugin support and a large community behind, Vim is the golden text editor you should start learning right now!

Vim plugins

Despite being a robust text editor, Vim doesn’t pack all the possible features possible. That’s why programs allow the usage of plugins. This is especially true to every well-known text editor. Plugins improve the functionality of the editor with various additional features that are not native to the editor.

In the case of Vim, there are a number of plugins available for all sorts of purpose. In fact, plugins are one of the strongest points of Vim. There are TONS of plugins out there to improvise Vim.

Installing Vim plugin

There are basically 2 different ways of installing a Vim plugin.

Manual installation

In this method, you have to manually grab the plugin from the web and put it in the target directory. Then, you have to update the vimrc file manually so that Vim always loads the plugin whenever you start Vim. If you update vimrc when Vim is running, it won’t load the updated file. Either restart Vim or tell Vim to reload the vimrc file.

There are different forms of Vim plugins. It can be either a “.vim” file, a Vimball file or, a set of directories with the expected structure (plugin/*, syntax/*, etc.). It depends on the plugin you’re going to install. If it’s a “.vim” file, put it into “.vim/plugin” directory. If it’s a Vimball file, we have to use Vim to install it. If it comes as the third type, it’s a bit tough to manually set all the files and folders with proper vimrc configuration.

Let’s get started with my favorite one. It’s actually a great way of theming the Vim editor. Check out the Vimrc by amix.

At first, make sure that your system has git installed. I’m running Manjaro Linux, an Arch-based distro with awesome look and fine-tuning. If you’re running any other distro, check out how to install Git on Linux.

sudo pacman -S git

As the GitHub page suggests, run the following command for completing the installation.

git clone –depth=1 https://github.com/amix/vimrc.git ~/.vim_runtime

sh ~/.vim_runtime/install_awesome_vimrc.sh

Once the installation is complete, check out Vim.

What happened? This plugin offers a simplistic way to put all the necessary files in place and updating the vimrc file accordingly. Check out the changes made to the vimrc file.

vim ~/.vimrc

As you can see, the “.vim” files are within a directory and the vimrc tells Vim to load those files whenever Vim starts.

Got a Vimball? Open the “.vba” file with Vim. Then, run the following command.

:source %

Vim plugin manager

This is the easiest way of managing all your Vim plugins. Almost all the manual tasks are taken care of. These plugin managers are super handy when you’re working with a large number of Vim plugins. Using a suitable plugin manager, you can make your life a lot easier.

However, the installation and usage of plugin managers can be a little bit tricky. Of course, the legacy of Vim requires you to be sophisticated enough to handle all the tasks efficiently.

Here are the most popular Vim plugin managers out there.

In this tutorial, we’ll take a look at vim-plug, my favorite plugin manager for Vim.

Vim-plug

Unlike other Vim plugin managers, vim-plug is very, very simple. There’s no need for any boilerplate coding. It’s just one single “.vim” file. Vim-plug is easier to install and the syntax are very simple.

Note: In the case of other Vim plugin managers, only the installation will be demonstrated.

Without further ado, let’s get started.

Installing vim-plug

Fire up the terminal and run the following command.

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

Configuring vim-plug

Now, it’s time to configure the vimrc for taking advantage of vim-plug. Add a vim-plug section in your vimrc file.

call plug#begin(‘~/.vim/plugged’)
call plug#end()

Notice the “~/.vim/plugged” parameter? It tells vim-plug to perform all the plugin actions in the directory. You should avoid using the default Vim directories like “~/.vim/plugin”.

Now, in-between the two declarations, there need to be all the plugins with the following structure.

Plug ‘<plugin>

For example, let’s enter the following line to enable the NERDTree, vim-easy-align and vim-github-dashboard plugins.

Plug ‘scrooloose/nerdtree’
Plug ‘junegunn/vim-easy-align’
Plug ‘junegunn/vim-github-dashboard’

Now, let’s take a look at the structure of the command. Notice the ‘scrooloose/nerdtree’ structure? Vim-plug will try to load the plugin from the GitHub directory. It’ll automatically be translated to https://github.com/junegunn/vim-github-dashboard.

There are some plugins that require extra actions after grabbing from the GitHub repo. Refer to the documentation of the associated plugins. The additional steps must be declared in vim-plug.

Plug ‘ycm-core/YouCompleteMe‘, { ‘do‘: ‘./install.py‘ }

In the above example, after grabbing the plugin, vim-plug will run the “install.py” Python script.

For all the possible functionalities of vim-plug, I strongly recommend consulting with the official vim-plug documentation on GitHub.

Loading all the plugins

Once the vimrc is properly configured, restart Vim or reload the vimrc file.

:so %

Finally, run the following command to start the installation of all the Vim plugins that were configured for vim-plug.

:PlugInstall

Vim-plug will download all the packages directly from GitHub and put them into the “~/.vim/plugged” directory and load them whenever Vim is loaded.

Updating plugin

Updating the plugin is quite simple. Just run the following command in Vim.

:PlugUpdate

Removing a plugin

If you want to get rid of a plugin, it’s quite easy. Just remove the entry from the vim-plug section of vimrc and call the following command.

:PlugClean

As you can see, vim-plug is asking whether you want to remove the files and directories.

Voila! Plugin removed!

Plugin status

Vim-plug also offers to check the current status of the plugin.

:PlugStatus

Other plugin managers

Here are the short intros to Vundle and Pathogen. Before jumping in, make sure that you’re using only one plugin manager for avoiding any unnecessary complexity and hickups.

Vundle

Short for “Vim bundle”, Vundle is a robust plugin manager with a ton of basic and advanced features. It can be compared to “apt” or “yum” that distros use

Install Vundle by running the following command.

git clone https://github.com/VundleVim/Vundle.vim.git ~/.vim/bundle/Vundle.vim

Just like vim-plug, Vundle requires a similar configuration of the vimrc file.

“ vundle must-have configs
set nocompatible
filetype off
“ configure runtime path
set rtp+=~/.vim/bundle/Vundle.vim
“ start Vundle plugin function
call vundle#begin()
Plugin ‘VundleVim/Vundle.vim’
Plugin ‘tpope/vim-fugitive’
call vundle#end()
“ another must-have for vundle
filetype plugin indent on

For all the possible functionalities, check out the Vundle on GitHub.

Pathogen

Pathogen is another powerful plugin manager for Vim. However, the internal mechanism of Pathogen is quite different than that of vim-plug or Vundle. It lets you directly manage the Vim ‘runtimepath’.

Installing Pathogen is quite easy. Grab the Pathogen plugin and put it into the “~/.vim” directory.

mkdir -p ~/.vim/autoload ~/.vim/bundle &&
curl -LSso ~/.vim/autoload/pathogen.vim https://tpo.pe/pathogen.vim

For manipulating the runtime path, add the following lines in the vimrc file.

execute pathogen#infect()
syntax on
filetype plugin indent on

Task complete! Now, any plugin you add at the directory “~/.vim/bundle” will be added to Vim ‘runtimepath’. For example, let’s install sensible.vim.

cd ~/.vim/bundle &&
git clone https://github.com/tpope/vim-sensible.git

For the full documentation, check out Pathogen on GitHub.

Final thoughts

Probably the best part of Vim plugin feature is, it’s ultra-stable and the plugin development is still ongoing strongly. If you’re in need of any help, the community got your back.

Feel free to explore your way around the amazing world of Vim plugins.

Enjoy!

ONET IDC thành lập vào năm 2012, là công ty chuyên nghiệp tại Việt Nam trong lĩnh vực cung cấp dịch vụ Hosting, VPS, máy chủ vật lý, dịch vụ Firewall Anti DDoS, SSL… Với 10 năm xây dựng và phát triển, ứng dụng nhiều công nghệ hiện đại, ONET IDC đã giúp hàng ngàn khách hàng tin tưởng lựa chọn, mang lại sự ổn định tuyệt đối cho website của khách hàng để thúc đẩy việc kinh doanh đạt được hiệu quả và thành công.
Bài viết liên quan

Cách lựa chọn proxy provider tốt nhất cho nhu cầu của bạn.

Khi bạn cần sử dụng proxy để truy cập vào các trang web bị chặn hoặc giới hạn về địa chỉ...
27/02/2023

Configure Vim with vimrc

Vim is an open source command line text editor. It is very powerful and customizable. In this article, I will show you...
29/12/2020

Hướng dẫn cài đặt MySQL-8.x trên Ubuntu-18.04

MySQL là một trong những hệ quản trị cơ sở dữ liệu mã nguồn mở rất phổ biến trên hệ thống...
30/12/2020
Bài Viết

Bài Viết Mới Cập Nhật

Thuê mua proxy Facebook chất lượng, GIÁ TỐT NHẤT
09/05/2024

Dịch vụ thuê mua proxy Zalo giá rẻ, tốc độ cao
09/05/2024

SỰ KHÁC BIỆT GIỮA RESIDENTIAL PROXY VÀ PROXY DATACENTER
17/02/2024

Mua Proxy v6 US Private chạy PRE, Face, Insta, Gmail
07/01/2024

Mua shadowsocks và hướng dẫn sữ dụng trên window
05/01/2024