Monday, August 11, 2008

Per-user Editor Selection in Ubuntu Intrepid

From the Ubuntu Server Team...

When a program in Ubuntu such as crontab -e or dch -i, is used to edit a file, it uses a helper program called sensible-editor (provided by the debianutils package).

sensible-editor attempts to intelligently find an editor on your system based on a few simple rules. Basically, if you haven't already defined $EDITOR, it will use one of {nano, nano-tiny, vi}, in that order.

Now, it's well understood that nano is easier to use than vi to a new Ubuntu user. And it's assumed that if you are sophisticated enough to want a different editor, then you likely already know how to change that setting.

Traditionally, this can be done in one of two ways.
  1. You can edit your ~/.bashrc file to export an EDITOR value of your choosing. Of course, that requires that you have a usable editor with which you can modify that file!
  2. Or if you are an administrator of the system, you can set the default editor for the entire system:
  3. sudo update-alternatives --config editor
So I recently created a new utility, /usr/bin/select-editor, which uses update-alternatives --list to display a list of editors present on the system and prompt the user to select one. The selection is written to ~/.selected_editor. I also patched /usr/bin/sensible-editor to read and use this value, if present.

The default selection remains nano, but for those of us installing dozens of Ubuntu systems every week and looking for a more powerful editor, we now have a really convenient, friendly mechanism for each user on an Ubuntu system to interactively choose an editor preference the first time they need one!

:-Dustin

No comments:

Post a Comment

Please do not use blog comments for support requests! Blog comments do not scale well to this effect.

Instead, please use Launchpad for Bugs and StackExchange for Questions.
* bugs.launchpad.net
* stackexchange.com

Thanks,
:-Dustin