How to install Vim on Ubuntu Linux

How to install Vim on Ubuntu Linux

Vim is the most popular text editing tool on Ubuntu and it is good for programming and editing configuration files on Linux. On Ubuntu, nano is the default command line text editor. If you prefer to use Vim, you can install Vim with apt the package manager.

To get vim install the vim-nox package:

sudo apt update
sudo apt install vim-nox

On Ubuntu desktop, if you want to use GUI-based version (GVIM) of the vim editor. Just install the vim-gtk package as well.

sudo apt install vim-gtk

Some system commands such as visudo use the system default text editor for editing configuration files (nano is the Ubuntu server default). But most system administrators prefer to use Vim.

This is done using the update-alternatives command:

sudo update-alternatives --config editor

Choose the selection number associated with Vim editor (in our case, 4) and press Enter.

Set Vim as default text editor