How can I change the default editor of the sudoedit command to be vim?
Run sudo update-alternatives --config editor
and choose for vim. After this, sudoedit /etc/hosts
should open /etc/hosts
using vim
.
Alternatively you can use sudo vim /etc/hosts
.
Try exporting the variable i.e.:
$ SUDO_EDITOR=/usr/bin/vim
$ export SUDO_EDITOR
A new shell is started when you run the command and if this variable is not exported it will not exist in the new shell.