"Joe's own editor" does not come naturally to me. How do I change to using nano or vim?
but it doesn't seem to be respected. I'd like
visudo to respect this as well.
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. It only takes a minute to sign up.Sign up to join this community
The way to change the default editor for your account is to set the
EDITOR environment variable. If that doesn't work for you, you've done something unusual. Check that you haven't also defined
VISUAL, or if you have, give the two variables the same value (see VISUAL vs. EDITOR – what’s the difference?). Add these lines to your
~/.profile (note: not to
EDITOR=nano VISUAL=$EDITOR export EDITOR VISUAL
Under the Debian policy, all programs are supposed to support
VISUAL to set the default editor.
I came across the very same issue, however setting it via update-alternatives did not quite do the trick on a Raspbian Buster (10.2). Although I set vim.basic as my default editor (manually using update-alternatives --config editor), it had only a priority 30, while nano had a priority of 40.
root@rsyslog:~/scripts# 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:
I started poking around in the usual profile- and dot-files and came accross the following one:
root@rsyslog:~/scripts# cat /root/.selected_editor # Generated by /usr/bin/select-editor SELECTED_EDITOR="/bin/nano" root@rsyslog:~/scripts#
After setting vim.basic via /usr/bin/select-editor, the file contained vim.basic:
root@rsyslog:~/scripts# /usr/bin/select-editor Select an editor. To change later, run 'select-editor'. 1. /bin/nano <---- easiest 2. /usr/bin/vim.basic 3. /usr/bin/vim.tiny 4. /bin/ed Choose 1-4 : 2 root@rsyslog:~/scripts# cat /root/.selected_editor # Generated by /usr/bin/select-editor SELECTED_EDITOR="/usr/bin/vim.basic" root@rsyslog:~/scripts#
Upon now I could do crontab -e with VIM again :).