The Linux text editor Joe has easy-to-remember keystrokes and allows you to customize it to suit your needs. Vincent Danen tells you how to tweak the configuration file to create keybindings and map your favorite commands.
A plethora of text editors exist that cater to a wide range of users. Editors like Emacs, Vim, Nano, and others are often installed by default on most Linux distributions for the command line, and other editors like Kate and Gedit are available on the GUI side. Another well-known editor is Joe (Joe's Own Editor) and it is my personal favourite.
A number of people who used the old WordStar editor enjoy using Joe as the keystrokes are similar. The keystrokes are also easy enough to remember for those who don't need all the power and added complexity of editors like Vim or Emacs.
With Joe, the primary keystroke is [Ctrl]K, after which follows the command. For instance, to get the help window to see the default keystrokes, use [Ctrl]K H. To search for text, use [Ctrl]K F. Other control commands are available, such as [Ctrl]V to move to the next screen of text, [Ctrl]A to get to the beginning of the line, and so forth.
Joe can be customized quite heavily as well. This is done by creating a personal ~/.joerc file. To begin, copy the system joerc, usually /etc/joe/joerc or /usr/local/etc/joe/joerc, to your home directory and then open it in a text editor.
$ cp /etc/joe/joerc ~/.joerc
$ joe ~/.joerc
This configuration file gives the building blocks to customize all aspects of Joe. It is already quite heavily populated, both with configuration items and comments. In the configuration file, a single space at the beginning of a line turns the rest of the line into a comment. For instance, the default setting for the -force option is disabled; it shows up as a comment:
To enable the option, which forces a final new line at the end of files when saved, simply remove the single space before the command:
If editing the file with Joe, comments will be shown in green.
Creating customized keys is quite easy as well. The F-keys are not defined at all in the default configuration file so they can be used to execute programs. For instance, if you wished to use ispell or aspell for spell checking, you could easily assign it to an F-key, such as F1. The configuration file already contains definitions for using aspell and ispell, but they are not bound to any keys. To bind the use of ispell to the F1 key, add:
When pushing F1 now, ispell will execute on the open document. If you wish to use aspell, use aspellfile instead of ispellfile.
To define a new macro, use the :def prefix and then the name of the macro, and its commands. For instance, to create a macro that inserts a copyright string, you might use:
:def copywrite "(c) 2008 Someone; all rights reserved."
copywrite ^[ O 2 P # SHIFT+F1
This defines the macro copywrite and then assigns it to a keybinding; in the above case, it is assigned to [Shift][F1].
If you are a serious Joe user, spending some time looking at the configuration file could be well worth it as all of the commands noted there can be tweaked and changed. You may even discover little tricks or keybindings you were not aware of before, and the ability to map favourite commands to F-keys or other keybindings can be a real productivity booster.
Get the PDF version of this tip here.
Delivered each Tuesday, TechRepublic's free Linux and Open Source newsletter provides tips, articles, and other resources to help you hone your Linux skills. Automatically sign up today!