|










Select from the choices above.
|
UNIX Text Editors
What is a Text Editor?
A text editor is strictly a general-purpose editor. It is not a wordprocessor.
It does not format the text; it does not have the handholding of a word processor;
it does not have built-in special facilities for editing binaries, graphics,
tables, outlines, or any programming language except perhaps Lisp.
A text editor is a computer program that lets a user enter, change, store, and
usually print text (characters and numbers, each encoded by the computer and its
input and output devices, arranged to have meaning to users or to other
programs). Typically, a text editor provides an "empty" display screen (or
"scrollable page") with a fixed-line length and visible line numbers.
You can then fill the lines in with text, line by line. A special
command line lets you move to a new page, scroll forward or backward,
make global changes in the document, save the document, and perform
other actions. After saving a document, you can then print it or display
it. Before printing or displaying it, you may be able to format it for
some specific output device or class of output device. Text editors
can be used to enter program language source statements or to create
documents such as technical manuals.
Most of UNIX revolves around text, so it's very important to learn how
to use these text editing programs. They are not quite as easy to use
as word processors or text editors on a personal computer, but if you
learn a few commands you'll be able to find your way around.
There are three main UNIX text editors, vi, emacs, and pico. You run
each of them by typing the name of the editor at the UNIX prompt followed
(optionally) by a space and the name of the file to edit.
vi, view, vedit (Visual Interface)
vi (pronounced by using each letter, vee-aye) is a widely-used and popular
UNIX-based text editor.
vi is a display-oriented text editor based on an underlying line editor ex.
ex is the root of a family of editors: ex and vi. ex is a
superset of ed, with the most notable extension being a
display editing facility. Display based editing is the
focus of vi. ed is the standard UNIX text editor.
red is a restricted version of ed. red will only allow editing
of files in the current directory. red prohibits executing
shell commands via !shell command. Attempts to bypass
these restrictions result in an error message (restricted
shell).
Like most UNIX system interfaces and other text editors,
vi lets you control the system by using the keyboard rather than a combination of
mouse selections and keystrokes. The succinctness of the interface makes it
highly useful for people who work at a computer all day, especially programmers
entering or manipulating language statements. vi was invented before and is a
popular alternative to emacs, a more capable, more complicated, and somewhat
slower text editor. Like emacs, vi is most commonly used for entering and
editing program language statements and for writing short notes including
email. vi usually comes as part of any UNIX-based system.
The vi editor (visual editor) is the default editor on most UNIX platforms.
While vi is not as intuitively easy to use as pico, it has many features
not readily available in the other text editors. To edit a file using vi,
type vi (with an optional filename) at the UNIX prompt, then press the [Enter] key.
vi has two modes; command and insert. When you enter the vi editor, you
are automatically placed in the command mode. Use the arrow keys to move
the curser anywhere in your text. (Note: the curser will not move anywhere
if you have entered vi without specfying a file).
Common Commands. Common commands for the command mode are:
- dd
- delete a line
- p
- replace the line just deleted one line below the current curser location
- r
- replace a character
- cw
- change the word starting at the current location of the curser
- dw
- delete a word
- dx
- delete a character
- ^F
- scroll forward on page
- ^B
- scroll backwards one page
- ^U
- move up 1/2 page)
- ^D
- move downward, 1/2 page
- /str
- search forward for the string designated by str
- L
- move cursor to the right
- H
- move cursor to the left
- J
- move cursor to down
- K
- move cursor to up
Changing to Insert Mode. There are a number of ways to change to the insert mode:
- i
- insert text at the current location of the curser
- I
- start entering text at the beginning of the current line
- a
- start entering text one space beyond the cursers location
- A
- start entering text at the end of the current line
- o
- begin entering information starting one line below the current line
- O
- start entering one line above
Continue entering text and when finished, use the ESC (escape key) to exit the insert
mode.
Exiting vi. To exit vi, you must be in the command mode.
ZZ will save your file and remove you from the editor. You can save your file
at anytime by entering :w, (press the shift key and the colon, then w, and
finally the [Enter] key). Similarly, :wq saves and exits vi, q or q!
exits without saving your file.
emacs (Editing MACroS)
emacs (derived from Editing MACroS) is a popular text editor used mainly
on UNIX-based systems by programmers, scientists, engineers, students, and
system administrators. Like other UNIX text editors, emacs provides
typed commands and special key combinations that let you add, delete, insert,
and otherwise manipulate words, letters, lines, and other units of text.
emacs is commonly used to enter the source statements for programs. emacs
itself is built using the Lisp programming language and users are invited to
extend or personalize it using the same language. emacs also offers a number
of convenient capabilities such as the ability to initiate program compilation
and to handle email from within the editor.
emacs was created by Richard Stallman
when he was at MIT. A popular version is called GNU emacs. emacs offers
a much longer list of commands than the other widely-used UNIX text editor, vi
and the ability to extend the interface. Like vi, the full capabilities of
emacs require a considerable investment in learning (or relearning if you
do not use them continually). However, a beginning set of commands makes it possible to
get to work immediately.
You start emacs by typing emacs, followed by the name of the file you wish
to create or edit, at the UNIX prompt. For example:
{strange.eng.utoledo.edu:101} emacs program.cpp
will run emacs and make a file called "program.cpp". The screen will clear to give
you a blank space to type. You may now begin to type. You can use the arrow
keys to move around and fix mistakes, and if you type off of the end of a
line it will automatically wrap to the next line. It's quite a nice editor.
Unfortunately, its (many, many) commands tend to be a bit obscure and
case-sensitive. Here are the more important ones:
Note: when a lower case letter appears below, it means lower case ... using
uppercase letter instead will not work.
- ^d
- deletes the character right after the cursor
- ^k
- deletes the current line
- ^y
- pastes the line you've just deleted back into the file
- ^x^c
- (press ^x first, then press ^c): quits emacs
and asks if you want to save your work.
- ^x^w
- (press ^x first, then press ^w): saves your file
It asks for a filename; leave it blank and press the [Enter]
key unless you want to change it.
- ^e
- go to the end of the line
- ^a
- go to the beginning of the line
- ^v
- scroll down a screenful
- ^h t
- (press ^h first, then press t): emacs tutorial
- ^h b
- (press ^h first, then press b): complete list of
emacs commands (and there are a LOT of them)
These commands should be enough to get you started.
pico (PIne COmposer)
pico is good beginner's text editor, because it looks exactly like pine,
the UNIX email program. That's because pine uses pico as its text editor,
so you should have no difficulty figuring out its commands. Most of the
important commands are displayed at the bottom of the window for easy
referance. If you're very comfortable with pine, this may be all you need.
emacs uses many of the pico commands, so it's easy to move up.
If you use pine to access your email, you are already familiar with pico.
Whenever you compose a letter in pine, you are using the pico editor.
To use this editor independently of pine, type pico (with an optional
filename) at the UNIX prompt, then press the [Enter] key. pico will place
you in a buffer which allows you to either insert or make changes on your
text file.
You will notice that pico contains a set of menu options at the bottom of the screen:
| ^G Get Help |
^O WriteOut |
^R Read File |
^Y Prev Pg |
^K Cut Text |
^C Cur Pos |
| ^X Exit |
^J Justify |
^W Where is |
^V Next Pg |
^U UnCut Text |
^T To Spell |
Note: the ^ symbol is translated as the control key (labeled Ctrl on most keyboards).
In order to make a pico command work, press and hold the control key and then tap the key for
whatever letter is called for by the command you desire.
When you use pico for the first time, issue the "Get Help" command
by pressing ^G and then review the brief listing of the various pico commands, including
many not listed on the menu illustrated above. To help get you started, here are
a few of the commands that you will need.
Editing
- ^D
- deletes a single character at the cursor position
- ^K
- allows you to erase a line
- ^U
- restores any erased lines inthe order in which they were erased.
Navigation
- ^F
- go forward one character
- ^B
- go back one character
- ^E
- go to end of line
- ^A
- go to start of line
- ^V
- go to next page
- ^Y
- go to previous page
File Management
- ^R
- command, which reads in a file located in your UNIX home directory
and inserts it at the cursor position.
- ^C
- Cancels the currently executing command
- ^O
- You can save your work at anytime without exiting pico by typing ^O.
- ^X
- When finished editing, enter ^X. pico will
prompt you with "Save modified buffer?" Type yes. If you started pico
without specifying a filename, pico will respond with a "File name to
write" prompt. If this file already exists in the current directory, pico
will prompt "File filename exists, OVERWRITE?" You can update this file by
typing Y. Or, type an N and pico again prompts for a name.
Unless otherwise specified, any file created by pico will be located within
the directory where you started your pico session.
joe (Joe's Own Editor)
joe is a powerful ASCII-text screen editor. It has a
"mode-less" user interface which is similer to many
user-friendly PC editors. Users of Micro-Pro's WordStar or
Borland's "Turbo" languages will feel at home. joe is a
full featured UNIX screen-editor though, and has many
features for editing programs and text.
- ^K H
- the first help window appears at the top of the screen
- ^F
- to move forwards (right)
- ^B
- to move backwards (left)
- ^P
- to move to the previous line (up)
- ^N
- to move to the next line (down)
- ^D
- to delete the character the cursor is on instead of deleting backwards like Backspace
- ^D
- will also delete a line-break if the cursor is at the end of a line
- ^Y
- to delete the entire line the cursor is on or
- ^J
- to delete just from the cursor to the end of the line
- ^A
- to move the cursor to the beginning of the line it's on
- ^E
- to move the cursor to the end of the line
- ^U
- for scrolling the cursor up 1/2 a screen's worth.
"Scrolling" means that the text on the screen moves, but the cursor
stays at the same place relative to the screen
- ^V
- for scrolling the cursor down
- ^K U
- to move the cursor to the beginning of the file
- ^K V
- to move the cursor to the end of the file
- ^_
- to "undo" a mistake
- ^K SPACE
- to have JOE report the line number, column
number, and byte number on the last line of the screen
- ^K X
- to exit the
editor. You will be prompted for a file name if you
hadn't already named the file you were editing
- ^C
- to exit the editor without saving
A number of control-key sequences are duplicated on other keys, so that you don't
need to press the control key:
- ESC
- will work in place of ^[
- Del
- will work in place of ^?
- Backspace
- will work in place of ^H
- Tab
- will work in place of ^I
- Return or Enter
- will work in place of ^M
- Linefeed
- will work in place of ^J
joe also emulates several other editors. JSTAR is a close
immitation of WordStar with many "joe" extensions. JPICO
is a close immitation of the Pine mailing system's pico
editor, but with many extensions and improvements. JMACS
is a GNU emacs immitation. rjoe is a restricted version
of joe, which allowes you to edit only the files specified
on the command line.
Although joe is actually five different editors, it still
requires only one executable, but one with five different
names. The name of the editor with an "rc" appended gives
the name of joe's initialization file, which determines
the personality of the editor.
joe was writen by Joseph H. Allen. If you have bug
reports or questions, email them to jhallen@world.std.com.
Larry Foard (entropy@world.std.com) and Gary Gray
(ggray@world.std.com) also helped with the creation of joe.
|