Vim is a highly configurable text editor built to make creating and changing any kind of text very efficient. It is included as “vi” with most UNIX systems and with Apple OS X.
Vim is rock stable and is continuously being developed to become even better. Among its features are:
- Persistent, multi-level undo tree
- Extensive plugin system
- Support for hundreds of programming languages and file formats
- Powerful search and replace
- Integrates with many tools
To install VIM on Ubuntu 20.04, just open a terminal from the main menu or by pressing the keys CTRL + ALT + T
and run the following
sudo apt update sudo apt install vim
After this, you can run it from the terminal and create/edit text files.
However, it is advisable to make some configurations to get VIM working properly.
By default, the global configuration file is /etc/vimrc
but the local user configuration file is ~/.vimrc
which is the one we will use.
nano ~/.vimrc
And add the following lines:
syntax on set expandtab set tabstop=4 retab set shiftwidth=4 set hlsearch set paste set ic set mouse=r
Save changes
What these variables do is add some settings to VIM. For example, set paste
allows us to use the clipboard to paste items. While set mouse=r
allows us to interact with the mouse in desktop environments.
Install and configure VIM plugins on Ubuntu 20.04
To install Plugins in VIM we have several ways including manual installation. However, thanks to the vim-plug
tool the process is much easier. That is why it is the preferred option for many and we will use it as well.
So, in a terminal, download and install vim-plug
by running
sudo apt install curl git curl -fLo ~/.vim/autoload/plug.vim --create-dirs https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim
For this example, I will install the NERDTree plugin but you can install any plugin you want.
Then inside the ~/.vimrc
file add the following lines
call plug#begin() Plug 'preservim/NERDTree' call plug#end()
Then every time you want to install a plugin you have to specify it following the above syntax. In this case, the NERDTree
plugin is hosted on Github so you only specify the user and repository name. In case the plugin is hosted elsewhere, you just have to specify the URL where it is.
Again, save the changes.
Finally, start Vim and tell vim-plug
to install the plugins listed in ~/.vimrc
using the command:
:PlugInstall
Now you have to wait for the process to finish.
Conclusion
Installing Plugins in VIM is easy with the vim-plug utility that makes it possible. In this sense, these plugins extend all the possibilities of the editor. There are too many plugins and this gives us the power to configure VIM the way we want.
So, do you like VIM? what do you think? leave us a comment and share the post.
Also, if you prefer nano, you can check our post:
Thanks for reading.