Per-user Editor Selection in Ubuntu Intrepid

August 11, 2008

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:
    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

About these ads

One Response to “Per-user Editor Selection in Ubuntu Intrepid”


Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.

%d bloggers like this: