How to set visudo editor on Debian using update-alternatives

“vi” as visudo editor
On Debian and derivatives, the editor “nano” is set as the default editor for visudo. If you do not want to edit sudoers using the command “visudo” with “nano”. But else use “vi” as the default editor, which was used as before by earlier Linux and Unixoid systems. You can change the editor with the help of “Debian Alternatives-System”.
$ sudo update-alternatives --config editor
There are 4 choices for the alternative editor (providing /usr/bin/editor).
Selection Path Priority Status
------------------------------------------------------------
* 0 /bin/nano 40 auto mode
1 /bin/ed -100 manual mode
2 /bin/nano 40 manual mode
3 /usr/bin/vim.basic 30 manual mode
4 /usr/bin/vim.tiny 15 manual mode
Press <enter> to keep the current choice[*], or type selection number:
Entering a number for the desired editor, to create symbolic link.
update-alternatives generates, removes, manages and displays information about the symbolic links that make up the “Debian Alternatives System”.
A directory, by default /etc/alternatives, containing the symlinks.
If you run it again, the setting can be checked with press the Enter key.
$ sudo update-alternatives --config editor
There are 4 choices for the alternative editor (providing /usr/bin/editor).
Selection Path Priority Status
------------------------------------------------------------
0 /bin/nano 40 auto mode
1 /bin/ed -100 manual mode
2 /bin/nano 40 manual mode
* 3 /usr/bin/vim.basic 30 manual mode
4 /usr/bin/vim.tiny 15 manual mode
set visudo editor on debian by update-alternatives
It is possible for several programs (text editors) fulfilling the same or similar functions to be installed on a single system at the same time. For example, many systems have several text editors installed at once. This gives choice to the users of a system. Allowing each to use a different editor, if desired, but makes it difficult for a program to make a good choice for an editor to invoke if the user has not specified a particular preference.
Debian’s alternatives system
Debian’s alternatives system aims to solve this problem. A generic name in the filesystem is shared by all files providing interchangeable functionality. The alternatives system and the system administrator together determine which actual file is referenced by this generic name. For example. If the text editors “ed” and “nvi” are both installed on the system. The alternatives system will cause the generic name /usr/bin/editor to refer to /usr/bin/nvi by default. The system administrator can override this and cause it to refer to /usr/bin/ed instead. And the alternatives system will not alter this setting until explicitly requested to do so.
The generic name is not a direct symbolic link to the selected alternative. Instead, it is a symbolic link to a name in the alternatives directory, which in turn is a symbolic link to the actual file referenced. This is done so that the system administrator’s changes can be confined within the /etc directory: the FHS (q.v.) gives reasons why this is a Good Thing.