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
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
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.
And inside the file add the following
call plug#begin() Plug 'rust-lang/rust.vim'. call plug#end()
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
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.
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
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
If you want to update all plugins
Or you can define which ones to update
PlugUpdate [plugin1] [plugin2]
Vim is a gem of an editor because it is fast and supports a wide variety of plugins. I hope you liked this post.