How to Install Vim Text Editor on Ubuntu

Vim is the enhanced version of vi text editor. Vim comes preinstalled on Ubuntu. The preinstalled version is minimal. To get the full version of vim, install vim using the apt or apt-get command.

Vim is a powerful text editor, which comes preinstalled in most Linux distributions. Ubuntu comes with Vim, vi, nano, Gedit (GUI), and many other text editors installed.

In this tutorial, we learn how to install VIM Text Editor on Ubuntu using apt.

Install Vim on Ubuntu

Vim is by default installed on Ubuntu. Vim is available in the Ubuntu repository. Ubuntu 20.04 comes with Vim 8.1 version.

To install the latest VIM package available in the repository follow the following steps.

Step 1. Update the Ubuntu package database

$ sudo apt update

Step 2. Install Vim using apt

$ sudo apt install vim

Step 3. Check Vim version

$ vim --version
Display Vim version

Now you can open, edit and save a file using VIM.

Compile Vim from the source file

Apt repository not necessarily contains the latest version, it takes some time to have the latest version there. If you are a fan of VIM and need the latest features of VIM, you can compile VIM from the source file.

As of writing this tutorial the latest available version available on the VIM website is 8.2

Let's check how to compile VIM using the source file.

First, install all the necessary prerequisite tools:

$ sudo apt install ncurses-dev
$ sudo apt install make
$ sudo apt install build-essential

Second, following the set to commands to download the source file and compile VIM:

$ wget https://github.com/vim/vim/archive/master.zip
$ sudo apt install unzip
$ unzip master.zip
$ cd vim-master
$ cd src/
$ ./configure
$ make
$ sudo make install

VIM is installed to the directory /usr/local/bin/vim. To install to a specific directory use ./configure --prefix=/path/to/install/vim.

Verify the Vim installation by typing vim -v or which vim.

Vim compiled - Version

Now we have the latest Vim 8.2 version.

The distribution provided Vim can be installed using apt remove vim, but it's not mandatory.

Conclusion

In this tutorial, we learned how to install Vim on Ubuntu using apt. We also learned how to compile Vim on Ubuntu to get the latest version.

Leave a Comment