Change default editor to vim system wide

i’ve used vi for over 30 years. i like it. i want to make it the default for every program that uses an editor - vipw, visudo, etc. none of the usual tricks seems to work - exporting EDITOR from .bashrc and /etc/bash.profile, update-alternatives, etc. and yes, i’ve installed vim.

this is a debian based system, yes? why doesn’t it behave like the other deb systems i use? how can i permanently change the default editor, system wide?

aside from this, it seems to work well. i’m just an old dog who doesn’t want to learn a new editor.

You are free to use any editor you want. Debian has many choices in their repositories, and you can always build from source if not accomodated there.

The default editor for Debian is actually nano.

Same way as any other Debian system.
sudo update-alternatives --config editor

I have no intention of changing the default editor. Helping new users is always an uphill battle. Most of them have little to no Linux experience. Forcing vim on people would not be beneficial. But, for those that know what they want, we do support freedom of choice and we won’t get in people’s way.

no bones to pick with not changing the default and i certainly meant no criticism. i’ve supported new users (still do at a local junior college) and i get why something other that vi (or emacs, for that matter) is the default. until you put your head around it, it’s the worst thing

i wouldn’t have posted had update-alternatives --config editor not thrown an error. that puzzled me.

ironically, i stepped away for a while and trying it again, it now seems to work. go figure.

thanks for the quick reply. i’m happy with the distro and despite being urged to try something different, i’ll stick with it.

If it happens again, please post the error.

Cheers

just wanted to update this thread as the above solution didn’t work for me and I had to add some more steps.

root@osmc:~# sudo update-alternatives --config editor
There is only one alternative in link group editor (providing /usr/bin/editor): /bin/nano
Nothing to configure.

Following command added vi into alternatives with priority 50:
sudo update-alternatives --install /usr/bin/editor editor /usr/bin/vi 50

Then I could choose what editor to use or kept automatic for the editor with highest priority:

root@osmc:~# sudo update-alternatives --config editor
There are 2 choices for the alternative editor (providing /usr/bin/editor).

  Selection    Path            Priority   Status
------------------------------------------------------------
* 0            /usr/bin/vi      50        auto mode
  1            /bin/nano        40        manual mode
  2            /usr/bin/vi      50        manual mode

Press <enter> to keep the current choice[*], or type selection number: 0

then exporting EDITOR variable and adding to your .profile (in your home directory) would be also good just to preserve the setting.

export EDITOR=vi

cd ~
vi .profile

add
export EDITOR=vi
at the end of the file and save the changes.

Well I’ve been using linux for a while and never knew there was an editor command. I set gvim as default on LinuxMint through the GUI but on OSMC, vim is fewer keystrokes than editor :slight_smile: