How To Install Vim on Ubuntu

September 29, 2022

Introduction

Vim (Vi Improved) is one of the clone versions of the text editor vi. With features such as syntax highlighting and new editing commands, Vim is one of the best text editors for the development environment.

Vim comes standard with most Linux distributions, but if you want the latest available version, you need to use Git.

In this tutorial, learn how to install the latest Vim editor on Ubuntu operating system.

Tutorial on how to install the Vim editor on Ubuntu

Prerequisites

  • A user with sudo privileges.
  • An Ubuntu system.
  • Ncurses libraries.
  • The following Linux packages: git, make, build-essential

Steps For Installing Vim on Ubuntu

To install the latest version of Vim on Ubuntu, first add the necessary prerequisite packages. Next, pull the latest image from GitHub.

Follow the steps below to install the latest version of Vim on your Ubuntu system.

Step 1: Install Necessary Tools

1. Before you install any application from GitHub, the system needs to meet certain requirements. Run the following commands:

sudo apt-get install libncurses5-dev libncursesw5-dev

This command installs two required ncurses packages. The last few lines in the output should look similar to this:

terminal output when installing ncurses packages


2. Once that's done, install git with this command:

sudo apt install git

3. After git, install the make tool. The make tool builds and installs packages from non-official repositories.

sudo apt install make

4. Finally, install the build-essential package which contains the necessary compiler:

sudo apt install build-essential

Give it a minute or two to complete, and you are ready to install the latest version of Vim from GitHub.

Step 2: Install Vi Improved (Vim) Text Editor

1. Download Vim from its GitHub repository to your machine:

sudo git clone https://github.com/vim/vim.git
git clone command to download files to your system

2. When the system finishes downloading the files, navigate to the download directory. In this case, go to the vim/src directory by typing:

cd vim/src

3. Build the software with the make tool. In the terminal, enter:

sudo make

Let the system finish building the program from its source code.

4. Place the program we just built to the correct location. This step includes Vim's libraries and documentation.

To do so, enter the following command:

sudo make install

The output should look similar to this:

output of sudo install make command ubuntu terminal after installing vim

Vim is now installed.

Step 3: Verify Vim Installation

To verify the installation process has completed successfully, check the version of Vim on your system.
In the terminal, run this command:

vim -v

The editor will open and show you the current version of Vim.

Vim version 9.0.619 output

How to Uninstall Vim

1. If you decide to uninstall Vim, remove it by running the following command from vim/src:

sudo make uninstall

2. Type in the sudo password and press y to confirm.

This removes the latest version from the GitHub repository. After this, you can use the apt install vim command if you want to return to the release from the official repository.

Conclusion

This guide showed you how to install the latest Vim editor on Ubuntu. Make sure you have all the tools available before you start building and installing Vim from the repository.

Was this article helpful?
YesNo
Sofija Simic
Sofija Simic is an experienced Technical Writer. Alongside her educational background in teaching and writing, she has had a lifelong passion for information technology. She is committed to unscrambling confusing IT concepts and streamlining intricate software installations.
Next you should read
How to Install Vim 8.2 on CentOS 7
September 10, 2019

Official repositories struggle to keep pace with updates and new software versions. This article provides ...
Read more
22 Best Linux Text Editors for Programming & Coding
September 3, 2019

A text editor is an application that lets you type text. All Linux distributions come with built-in editors ...
Read more
How to Create a File in Linux Using Terminal/Command Line
June 27, 2019

Creating a file in Linux might seem straightforward, but there are some surprising and clever techniques.
Read more
How to Save a File in Vi / Vim & Exit
September 22, 2022

Vim (Vi IMproved) is a well-known, open-source text editor for Linux or Unix systems. It is a powerful and ...
Read more