How to install the latest Vim on Ubuntu 16.04

What is Vim?
Vim is a highly configurable text editor built to enable efficient text editing. It is an improved version of the vi editor distributed with most UNIX systems. Read more.
Install the download and build dependencies
We can download package information from all configured sources:
$ sudo apt update
We need to install Git in order to download the latest version of Vim from the official repository:
$ sudo apt install -y git
In order to get the latest version of Vim, we’ll be compiling and installing the software from source. We need to satisfy the build dependencies so that we can compile the software.
To do this, we can install the build-essential
package:
$ sudo apt install -y build-essential
Download, compile and install Vim
We need to choose the target directory where we’ll download Vim.
Let’s download in the /tmp/vim
. Before downloading we need to try to remove /tmp/vim
to ensure that this directory isn’t busy:
$ rm -fr /tmp/vim
Download Vim to /tmp/vim
:
$ git clone https://github.com/vim/vim.git /tmp/vim
Compile the Vim binaries:
$ make -C /tmp/vim
Install the binaries into the system:
$ sudo make install -C /tmp/vim
We don’t need to keep the downloaded Vim binaries, so we can remove /tmp/vim
:
$ rm -fr /tmp/vim
Successfully finishing all steps above we can use the latest vim
. Enjoy!
All steps together:
#!/usr/bin/env bash
sudo apt update
sudo apt install -y git
sudo apt install -y build-essential
rm -fr /tmp/vim
git clone https://github.com/vim/vim.git /tmp/vim
make -C /tmp/vim
sudo make install -C /tmp/vim
rm -fr /tmp/vim