Cómo instalar plugins en Vim y darle superpoderes

Author
By Darío Rivera
Posted On in Vim

Vim is usually underestimated as a text editor. In part, it's because people don't know how much it can do and how to start giving it the functionalities of big editors or development IDEs like phpStorm, Visual Studio Code, among others. Today, you'll learn how to install a plugin manager for Vim that will open a world of possibilities for you.

vim-plug manager installation

For Vim, there is a long list of plugin managers, of which we will see the one I think is the most popular, vim-plug. To install this manager, you must execute the following command (UNIX):

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

You will get a similar output to the following, indicating that you have installed it correctly.

  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100 82402  100 82402    0     0   235k      0 --:--:-- --:--:-- --:--:--  235k

Plugin Installation

The next thing you need to do is indicate the plugins you are going to install. This is done by editing the ~/.vimrc file. If it doesn't exist, you can create it and add the following content to it.

call plug#begin()
Plug 'tomasiser/vim-code-dark'
call plug#end()

"colorscheme codedark

As you can see, the plugin block declaration is described in the first three lines of code, where the middle line indicates that we want to add the tomasiser/vim-code-dark plugin. This plugin will make our editor have an appearance inspired by the dark theme of Visual Studio Code. Note that we have commented out the theme declaration (colorscheme) since the plugin should be installed before declaring the theme to use. 

After this, and whenever you need to install a new plugin, you must execute the following command. You can do this on the same Vim if you used it to create the ~/.vimrc file.

:PlugInstall

Once this is done, you can uncomment the colorscheme line and then close Vim and open a new file to validate the theme. If you're already in Vim and don't want to exit, you can use the following command:

:source ~/.vimrc

With this, you will also check immediately that you have not had any syntax errors. After this, you can execute the plugin installation command. You will get output like the following:

- Finishing ... Done!
- vim-code-dark: remote: Total 24 (delta 0), reused 20 (delta 0), pack-reused 0

If you saw that it opened a different file than the current one, you can close it with :q. Then, if you're still in the editor, you can load the configuration as you saw earlier, and your editor will change its appearance.

In the end, you will see in Vim an interface similar to the following:

vim code dark


Acerca de Darío Rivera

Author

Application Architect at Elentra Corp . Quality developer and passionate learner with 10+ years of experience in web technologies. Creator of EasyHttp , an standard way to consume HTTP Clients.

LinkedIn Twitter Instagram

Sólo aquellos que han alcanzado el éxito saben que siempre estuvo a un paso del momento en que pensaron renunciar.