How to install and use Vim plugins

Everything Linux, A.I, IT News, DataOps, Open Source and more delivered right to you.
Subscribe
"The best Linux newsletter on the web"

Hello, friends. Recently, you learned how to install Vim in Ubuntu 22.04. This powerful text editor that emerges as an improvement to the mythical vi also has support for plugins. Today, you will learn how to install and use Vim plugins.

One of the most important reasons to use vim is that it is fast, lightweight, efficient and because it supports many important plugins. These plugins further increase the functionality of the editor and turn it into a Swiss army knife that can help us with almost anything.

There are two ways to install plugins in Vim. The first one is manually, where we will have to download each one of the plugins. Although this process is safe and very efficient, the truth is that if you are going to install several, it will not be so much.

On the other hand, there is a tool called Plugin Manager that facilitates the whole process. It also allows you to keep the plugins updated, and it really makes everything easier. I think this is the best possible method for newbies and not so newbies.

Install Vim Plugin Manager

Let’s see, strictly speaking, the tool is called vim-plug and according to the GitHub profile is

A minimalist Vim plugin manager.

So simple and clear. Thanks to it, you will be able to install plugins quickly. But not only that, you can also update and uninstall them.

To install it, just run this command

curl -fLo ~/.vim/autoload/plug.vim --create-dirs https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim
Download vim-plug to install plugins on Vim
Download vim-plug to install plugins on Vim

And you’re done! Yes, it’s that easy. Of course, remember that for this to work, you have to install vim and curl.

Installing and using Vim plugins

There are many plugins for Vim, but to demonstrate the tutorial, I will install rust.vim which is a plugin that adds syntax highlighting for Rust programming.

To install plugins with vim-plug you need to define them in a text file. This file is ~/.vimrc which, if it does not exist, you can create it.

nano ~/.vimrc

And inside the file add the following

call plug#begin()

Plug 'rust-lang/rust.vim'.

call plug#end()
Define plugins to install
Define plugins to install

Now as you can see for each plugin you have to add a new line inside the call statements indicating the start and end of the definition.

The syntax of Plug is repository/plugin and to know it you need to visit the website or GitHub profile of each plugin.

In this case and thanks to the documentation presented by rust.vim you know how to make the correct definition.

Save the changes and close the editor. Now open vim.

Install and use Vim plugins
Install and use Vim plugins

And without doing anything else inside the editor, run PlugInstall and press Enter.

As soon as you do this, you will see how the wizard will make all the necessary changes to install the plugins.

If all goes well, you will see a message like this

Vim plugins installed
Vim plugins installed

To finish the whole process, restart Vim and you will be able to use your plugins.

Bonus: Some important commands for vim-plug

To better handle this plugin manager for Vim, it is good to know some important commands.

To upgrade the tool to the latest version, run inside Vim

PlugUpgrade

If you want to update all plugins

PlugUpdate

Or you can define which ones to update

PlugUpdate [plugin1] [plugin2]

Conclusion

Vim is a gem of an editor because it is fast and supports a wide variety of plugins. I hope you liked this post.

Everything Linux, A.I, IT News, DataOps, Open Source and more delivered right to you.
Subscribe
"The best Linux newsletter on the web"
Angelo
Angelo
I am Angelo. A systems engineer passionate about Linux and all open-source software. Although here I'm just another member of the family.

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Latest articles

Join us on Facebook