Introduction to Unix |
|
![]() |
![]() |
2.11. Using Text Editors¶
Linux for Programmers and Users, Section 3.36
Text editors are one of the most frequently used applications on Unix systems. They are used to create and edit files in plain text format. With the emphasis on plain text data, text editors are as important or more so than word processors, such as Open Office. Text editors are also often used when developing program source code and even documentation. Text formatters, such as LaTeX and reStructuredText, which is used to generate this study guide, are still often used by Unix users.
Note that all of the editors mentioned here may be ran using a traditional console terminal without the use of a mouse. This makes these editors useful when remotely connected to a computer as well as when logged in on the console of a Unix system. Gvim and XEmacs do provide mouse support, but may also be used without a mouse. Mouse support is occasionally handy, but also requires the user to move a hand away from the keyboard, which tends to slow down the editing process.
2.11.1. emacs¶
emacs was developed by Richard Stallman in 1976. Richard Stallman is also well known as the developer of gcc (open source C compiler) and as the founder of the GNU Free Software Foundation. Emacs has, perhaps, more editing commands than other editors, numbering over 1,000 commands. It also allows the user to combine these commands into macros to automate work. The XEmacs version of emacs has a graphical user interface. Emacs has only one mode (input), like most other editors in common use today.
Note
A very knowledgeable friend of mine working at AT&T Bell Labs once jokingly referred to emacs as the Carpal Tunnel editor, since most of the commands in emacs are accesses by typing multiple keys on the keyboard at the same time.
It is for this reason and that I was already fairly proficient with vi before ever hearing of emacs that I choose vi instead of emacs. However, very many talented Unix users love emacs. It is a matter of personal taste.
2.11.2. vi¶
The original vi (visual editor) was developed by Bill Joy in 1976 as part of BSD Unix system. Bill Joy was later one of the co-founders of Sun Microsystems. vi became popular very fast within the Unix community as it provided a full screen, visual editor, which was missing before. It is still the standard text editor that is available on any Unix system. The newer vim and graphical gvim, do add many nice features to vi.
Note
One reason to become proficient with vi is that on some industrial type systems with no extra software installed, vi may be the only editor available.
By an industrial system, we mean a computer that has a primary job, such as controlling equipment, and is not intended to be any user’s daily workstation. One example of such a system is telecommunications equipment, such as a switch.
An issue that some users have with vi is that it has three modes:
- input
- command
- ex or colon
In command mode, one can move around on the screen, search the document for words or phrases, delete portions of text and move text around. From the command mode, on can enter input mode by typing anyone of the letters: i, a, o, O or c (for insert, append, new line below current, new line above current and change). In input or insert mode, one types text into the document and returns to command mode by pressing the <Escape> key. From the command mode, one can type a colon (:) to enter the ex mode. In ex mode, commands may be entered so save the file, edit another file, read in another file, create or append text to another file or to move, copy or delete blocks of text from the document.
The following diagram shows a cheat sheet for all of the vi commands. The multiple modes of vi may seem to strange to beginners, but in time, they feel quite natural and allow edits to be made very quickly.

2.11.3. nano¶
The user interface of nano and pico are identical. pico became well known and popular because it is default editor used with the pine e-mail client. Pine is an easy-to-use text based e-mail client that was very popular a few years ago when most users connected to the Internet via dial-up modems and most e-mail messages only contained plain text data. Pine and pico were developed by the University of Washington. They are free programs, but not open source programs. They are free in the sense of free beer, but not in the sense of free speech. Thus installation packages of pine and it’s editor pico are readily available for many Linux distributions. Enter nano – an open source clone of pico.
nano is very easy to use for beginners. However, it lacks the advanced features of vim and emacs. Serious users, will want to eventual use an editor with more features, but nano will get the job done for the casual Unix user.