50

I have used select-editor and I note that I am using /usr/bin/nano. Is this the default text editor I am using?

When I open text files, It opens with gedit

What command in terminal must be specified to get the default text editor that I am using, and have it returned to e in terminal?

Pablo Bianchi
  • 14,308
  • 4
  • 74
  • 117
Nau Nau head
  • 603
  • 1
  • 5
  • 4

3 Answers3

70

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"
Maythux
  • 82,867
  • 54
  • 239
  • 271
  • Ah.. I see.. thats why I was confused with the both type of editors.. – Nau Nau head Apr 28 '15 at 06:53
  • nevermind,, this is an environment variable,,, it's not set in your system, you can set it by `export EDITOR=/usr/bin/nano` and add to the `.bashrc` – Maythux Apr 28 '15 at 06:55
  • 1
    @NewUSer some programs let the value of `VISUAL` override the value of `EDITOR` as well. – muru Apr 28 '15 at 06:59
  • Thanks, very informative.. so there is no way to extract the default command line editor? I am able to extact the GUI editor from defaults.list – Nau Nau head Apr 28 '15 at 07:01
  • @muru Thanks for your note yeah sure im going to edit the answer – Maythux Apr 28 '15 at 07:05
  • @NauNauhead yeah you can do so – Maythux Apr 28 '15 at 07:07
  • nitpick: Only `ed` of the mentioned editors is truly a command-line editor. Others are more interactive and don't actually operate on a command line at all. Complement of a GUI app is TUI, or terminal application. CLI apps is a smaller subset of terminal apps. – mike3996 Apr 28 '15 at 12:05
  • Actually some tools use `sane-editor` as the editor, but luckily it also respects `$EDITOR`. – Franklin Yu Nov 01 '20 at 21:26
  • checked with Ubuntu - found there is no such $EDITOR variable. a user can provide it on its own but its better to assume it might not be there. – Alexander Stohr Jun 02 '23 at 13:58
1

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.

Jon Mod
  • 11
  • 1
0

with update-alternatives there is the alias application entry point (probably reachable via your executeable path):

/usr/bin/editor

that might link to:

/etc/alternatives/editor

that then finally links to your configured application.

these command line will report much of extra information including any lesser ranking options than the default:

update-alternatives --query editor

the respective default selection and more setting options can be updated by these interactive shell command:

sudo update-alternatives --config editor

find more information at the man page of those system helper tool:

https://man7.org/linux/man-pages/man1/update-alternatives.1.html

or on web pages like that:

https://linuxhint.com/update_alternatives_ubuntu/

  • What does this add to the already accepted answer ? – Luuk May 23 '23 at 12:02
  • it categorizes what a specific name means. here the reader is meant for discovering the "ocean" from shallow to deep so his natural learning curve is encouraged. my impression... the gap for this and other aspects in the original writing was too big for fixing it in place and still stay clealy understandable. – Alexander Stohr Jun 02 '23 at 13:55