Changing default text editor in a terminal

This has been frustrating me for a while every time I use midnight commander to edit a file the nano editor keeps appearing, I’ve been used to using vi since I first started using UNIX in the 90’s so its a bit like trying to teach an old dog new tricks. The problem is midnight commander uses the default editor for the session, unless you tell it to use the internal editor. Typically I would edit the bash.bashrc and add vim as editor in there.

However I have found out a better way by using

sudo update-alternatives --config editor

This will bring up a small menu with the editors you have installed, simply choose the one you wish to use.

Changing the Default Bash Editor

3 thoughts on “Changing default text editor in a terminal

  1. That solution works only for debian distributions, not for redhat (centos, fedora). It would be nice to know how to setup nano as default editor for midnight commander.
    Thank you

    • Thanks for your comment. Yes indeed it does only work for debian distributions, I only use Linux Mint so all my tips are based around that, sorry for the confusion on that. I’ll make sure that I let people know what distributions the tip will work on in future.
      In answer to your question to set the default editor in midnight commander you can do the following:

      export EDITOR=/usr/bin/nano

      If you place this in the .bashrc file in your home directory Midnight Commander will then use nano.

      Hope this helps

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.