Getting the default text editor used in system

First of all you should notice that there are two types of text editors..

  1. The command line editors such as vim, nano, emacs, etc..
  2. GUI text editors such as gedit, kate, ...

The default text editor when using the GUI is not the same as the command line text editors so when you are opening a file using GUI you probably are using the GUI text editors which is gedit by default. While when using the command line so you are using the command line text editors.

To know that is the default command line text editor in your system you can try one of the following methods:

First Method:

sudo update-alternatives --config editor

This command show you the text editors. The one you are using has the * in front

  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    10        manual mode

Second Method:

$ echo $EDITOR
/usr/bin/nano

to set the default editor you can add the following to your shell configuration ( ~/.bashrc):

export VISUAL="/usr/bin/nano"
export EDITOR="$VISUAL"

In my setup none of the common ways to change the default editor worked. So I just:

#~/.bashrc
alias edit=nano

Was all that I wanted anyways.