Debian – Putting a new/graphical editor in editor list

debiandpkgeditors

I had put up a query before, and then wanted to put leafpad in editor list but wasn't able.

[$] sudo update-alternatives --set editor /usr/bin/leafpad                                                                       
update-alternatives: error: alternative /usr/bin/leafpad for editor not registered; not setting

Having a look-see saw this list –

└─[$] sudo update-alternatives --config editor

There are 8 choices for the alternative editor (providing /usr/bin/editor).

  Selection    Path                Priority   Status
------------------------------------------------------------
* 0            /usr/bin/le          60        auto mode
  1            /bin/ed             -100       manual mode
  2            /bin/nano            40        manual mode
  3            /usr/bin/emacs24     0         manual mode
  4            /usr/bin/le          60        manual mode
  5            /usr/bin/ne          20        manual mode
  6            /usr/bin/nedit       40        manual mode
  7            /usr/bin/vim.basic   30        manual mode
  8            /usr/bin/vim.tiny    15        manual mode

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

Have no idea why leafpad can't be registered as a valid editor. If you do get dumped to console and can't use graphical editor for whatever reason, you could always run sudo update-alternatves –config editor and fix the same. Is this a bug or something that needs to be fixed either at leafpad or at update-alternatives/dpkg side ?

Best Answer

The syntax is usually

update-alternatives --install link name path priority

(plus a few optional arguments that I omitted).

So you could do like this:

update-alternatives --install /usr/bin/editor editor /usr/bin/leafpad  0

Then you can re-run that same command and choose leafpad to be your editor.

In my example I gave it a priority of zero. You can choose something different. It only affects when the alternative goes to automatic mode. Don't give Leafpad a high priority, though. You don't want a graphical editor being the default choice in case anything goes wrong and the package is automatically reconfigured.

Related Question