The problem is not that it does not apply to nano, it's that it does not apply to the shell:
Just set the VISUAL environment variable:
export VISUAL=vim
Add this too ~/.bashrc to make it permanent.
As you seem to use vim in general, set both VISUAL and EDITOR:
export VISUAL="vim"
export EDITOR="$VISUAL"
or more POSIX-correct
VISUAL="vim" ; export VISUAL
EDITOR="$VISUAL" ; export EDITOR
I assume nano was the value of one or both variables.
To make use of the editor in visudo actually, we need to handle that sudo does not keep the environment variables by normally. The option -E changes that.
sudo -E visudo
Without the -E here, you would end up with a default of nano again
The two variables where in use long before files named *.desktop or mime* even existed.
(And the impressive thing is: they were actually used as a common standard.)
In Ubuntu, the system default seems to be set with sudo update-alternatives --config editor. It shows a menu to change the current association.
See section ENVIRONMENT in man visudo:
VISUAL Invoked by visudo as the editor to use
EDITOR Used by visudo if VISUAL is not set
man visudo? – fkraiem Oct 01 '14 at 20:53sudo -E visudolater in the answer, did you try that? The -E makessudonot remove all env vars. It does because ubuntu has a lineDefaults env_resetin/etc/sudoers– Volker Siegel Oct 02 '14 at 19:14update-alternativesI also added? – Volker Siegel Oct 02 '14 at 19:16