Change the default editor for Visudo
Visudo is a tool used to safely edit the sudoers file. Visudo locks the sudoers file to ensure multiple users are not trying to edit the file, as well as performing basic sanity checks, and checks for parse errors.
The sudoers file is where you edit the options for sudo. Such as allowing a user to use sudo for all programs – or a handful of programs they require.
To make things easier for people new to Linux, the default editor for Visudo on some Linux distros (i.e. Ubuntu) is Nano. I’ve never really got used Nano. So to make things easier for me I like to swap it back to Vim.
To make changes, we will first have to enter the following command to safely edit the sudoers file.
sudo visudo
This of course will open with nano. Replace the line:
Defaults editor=/usr/bin/nano
with
Defaults editor=/usr/bin/vi
and save your file.
Visudo will now open with Vi, the way the greybeards of old intended.