Why do people run away from Vim?
- When you open VIM for the first time then you will see a blank screen without any menu etc.
- There is no sidebar showing the project structure.
- If you open any file let’s say javascript or CSS or HTML then there is no syntax highlighting.
- If you want to edit multiple files then you first open the first file edit it close it and then again open the second file edit it close it.
- There is no color scheme and everything looks like black and white
- Also no information like
- total lines in the document
- Where the cursor is currently
All these things scare people and they move to either sublime, Atom, or JetBrains, etc.
But don’t fear Plugin Managers are there.
Yes, you heard it right there are several Plugin Managers to help you out and customize VIM for your own development needs.
What does a Plugin Manager do
As the name suggests you can plug new things into your vim and make it awesome. Plug Manager helps us to manage the plugins that you have installed in your VIM for your development needs.
Some of the Plugin Manager used by the developer community are
- Pathogen
- Vim-Plug
- Vundle
We will be using Vim-Plug as our plugin manager
Installation Vim-Plug
curl -fLo ~/.vim/autoload/plug.vim --create-dirs \
https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim
When you run the above command then curl visits the URL
https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim and download this file to your local machine at the path ~/.vim/autoload/
This is all that Vim does to install the Vim-Plug plugin manager.
What happens when you run the command vim
This is the most important concept that needs to be understood.
When you run the vim command in our terminal then it reads the file .vimrc present in your home folder and configures vim according to the settings present in the .vimrc folder
To find your .vimrc file you need to go to your home directory
cd ~
It may happen that if you are using Vim for the first time then the .vimrc file may not be present.
If there is no .vimrc file then just create your own
touch ~/.vimrc
All your settings related to Vim will go inside your .vimrc file
Activating plugin manager
You have installed Vim-Plug but it will not show any changes in your Vim because the necessary settings for Vim-Plug have not been done in your .vimrc file
To configure your Vim with Vim-Plug you need to open the .vimrc file
vim ~/.vimrc
You need to put these lines to the .vimrc file
call plug#begin()
call plug#end()
All the list of your plugins will go inside the blank space present between call plug#begin() and call plug#end.
so the next time you will open your Vim then it will try to call the plugin manager Vim-Plug and inject the necessary settings into your Vim.