I want the opposite of the usual request to use nano: I want to use either my $EDITOR or just hardcode to vim. If I follow the linked instructions (or “change the editor of choice” wiki instructions) I still end up with nano when invoking sudo visudo.
debugging details on what i’ve tried below,but you can probably stop reading now
debugging (what I’ve tried):
$ sudo visudo
# add this atop the file:
Defaults env_reset
Defaults editor=/usr/bin/nvim:/usr/bin/vim:/usr/bin/vi:/usr/bin/nano, !env_editor
$ # above exited without issues
$ file /usr/bin/nvim
/usr/bin/nvim: ELF 64-bit LSB pie executable, x86-64, version 1 (SYSV), dynamically linked, interpreter /lib64/ld-linux-x86-64....
$ echo $EDITOR
nvim
$ sudo visudo
# nano launches
(the last step is the unexpected one)
further debugging
Here are things I’ve tried as single-swap ins for the sequence above (none of these worked):
just one editor= value in sudoers file
I’ve tried setting the right-hand-side value of the editor= line with just one editor (seems fragile to me, but just for debugging’s sake):
$ sudo visudo
visudo: no editor found (editor path = /usr/bin/nvim)
(after this^ I fixed it by, unfortunately, just editing the sudoers file by hand, and testing that fixes things without new breakage in another terminal before exiting).
full $EDITOR path in my shell
I’ve set full path for EDITOR instead, eg: export EDITOR=/usr/bin/nvim before calling sudo visudo but that makes no difference in behavior. I thought this might be key, as the man page for visudo made me think, maybe it’s just doing a naiive string match to the $EDITOR value (rather than like.. a basename $EDITOR match). Doing this with or without the above editor= tweak makes no difference.

