Text Editors for Embedded Systems

This document highlights some of the smaller, and therefore more popular, text editors that are available on many embedded systems. Embedded systems are often deployed using writable filesystems in order to create configuration, log, and application data across system restarts. Although configuration files can be created on the host systems and transferred to the target, it is often necessary to create and edit text files directly on the embedded system.

vi versus emacs

Screen-oriented Linux text editors are available as two basic types: modal and mode-less. The older Linux screen editors are modal editors, in which key sequences have different meanings depending on whether you are in the editor’s “command” or “insert” modes. The best-known modal editor is vi and its clones. For example, in command mode in vi, the i key switches the editor to insert mode. In vi’s insert mode, the i key inserts the letter “i” at the current cursor position in the file that you are editing.

The other type of screen-oriented editor is a mode-less editor, in which the editor is always in insert mode, and commands are executed by using the Control (Ctrl) and Escape (Esc) keys to modify other characters. For example, in emacs, pressing the letter e inserts the letter “e” at the current cursor position in the file that you are editing, while holding down the Ctrl key and pressing the letter e moves the cursor to the end of the current line. Pressing and releasing the Esc key followed by the e key moves the cursor to the end of the current paragraph.

Which of these types of editors you use depends on a number of things, especially your comfort level with each type of editor and the amount of filesystem space that you’re willing to squander on a text editor. Almost everyone who has worked on a UNIX or Linux system knows a few basic vi commands, and for this reason vi-like editors are viewed as the standard for embedded systems.

vi Clones for Embedded Linux Systems

If your embedded system uses BusyBox, you can add a text editor to your embedded system by activating vi support in the BusyBox configurator’s Editors pane. Building and installing BusyBox for your system will build vi capabilities into the BusyBox binary, and will create a link called “vi” to the BusyBox binary. The BusyBox vi implementation only provides a subset of the standard vi commands, but the most important ones are there: indent, delete, move the cursor, save, and quit.

The best known, more full-featured vi clones are nvi (new vi) and vim (vi improved). (You can get more information about nvi at http://www.bostic.com/vi/, and on vim at http://www.vim.org/.) Both of these can be quite large if compiled with all of the available features, but they are easy to reduce in size by using such things as optimization and by reducing the available command set. The nvi clone has always been popular on BSD-type UNIX systems, while vim is more popular on Linux systems.

You can get information about other vi clones at http://www.saki.com.au/mirror/vi/clones.php3.

emacs Clones for Embedded Systems

GNU emacs is a huge binary that provides every possible capability and can load external files containing function definitions to grow even larger. This size is impossible to use on smaller and embedded systems, so many small emacs clones are available. The Wikipedia entry for emacs (http://fabrice.bellard.free.fr/qemacs/) provides a good history of emacs and pointers to its many clones. A few of the more useful ones for embedded systems are listed below:

One of the best-known of the emacs clones is e3 (http://www.sax.de/~adlibit/). If you are more familiar with vi, but e3 is the available editor, e3 can be compiled to support vi key bindings.

Another popular embedded emacs implementation is the jmacs binary, produced when compiling the JOE editor (http://www.sax.de/~adlibit/). By default, JOE uses WordStar key bindings that few living people remember, but old habits (and key bindings) die hard.

The qemacs clone (http://fabrice.bellard.free.fr/qemacs/) supports a much larger set of default features than a pure editor such as e3, including scaled font support, the X Window system, XML, and Docbook. However, all of these options can be disabled during compilation to provide a small, powerful emacs clone without any additional bells and whistles.

A final emacs clone is MicroEmacs (http://fabrice.bellard.free.fr/qemacs/), which is a time-tested emacs implementation that has been around since the early days of the microcomputer. Since it has run on hundreds of different types of systems, some with 64K or so of memory, MicroEmacs is a good choice if you must have emacs but want more power than e3 provides.