Brief: This quick tutorial shows the steps for installing the latest version of Vim on Ubuntu Linux.
Vim is one of the most popular terminal-based text editors. However, it is not installed by default on Ubuntu.
Ubuntu uses Nano as the default terminal editor. Nano is also an excellent tool and I am not going into Nano vs Vim debate.
If you have already spent some time mastering the Vim shortcuts, you don’t have to forget them and start using a new editor.
You can install Vim on Ubuntu using the following command in the terminal:
sudo apt install vim
That’s quite simple, right? This approach’s major problem is that you won’t get the latest Vim version.
You can check the installed Vim version with the following command:
And if you check the Vim website, you’ll find that Vim has newer versions released already.
At the time of writing this article, Vim 9.0 is released but is not available in Ubuntu repositories yet.
The good news is that you can install the latest Vim using an unofficial but actively maintained PPA.
Install Vim 9 on Ubuntu using a PPA
If you have specific Vim configuration files, there is no harm in making a backup for them.
Now, to install the latest Vim version, add the PPA repository first:
sudo add-apt-repository ppa:jonathonf/vim
You don’t need to update the package cache on Ubuntu but other distributions like Mint may still require it:
sudo apt update
Now, use the command below to install the latest Vim version offered by the PPA:
sudo apt install vim
If you had already an older Vim version installed, it would be upgraded. You can check the installed Vim version using:
This is a very well-maintained PPA and is available for all active Ubuntu versions.
If you are new to this PPA thing, I have a detailed guide on this topic. You should read to learn more about the concept of PPA in Ubuntu.
Downgrade or remove it
If you want to go back to the older Vim version provided by Ubuntu, you should remove the existing version, remove the PPA and install it again.
Before removing Vim, you should copy the vimrc or other such config file if you had made custom changes and plan to use Vim again.
Alright. Open a terminal and use the following command:
sudo apt remove vim
Now delete the PPA otherwise you’ll get the latest Vim again (if you try installing Vim for the older version):
sudo add-apt-repository -r ppa:jonathonf/vim
Now, if you want the old, official Ubuntu version of Vim, just install it again using the apt command.
Enjoy Vim on Ubuntu.