- 论坛徽章:
- 0
|
Chapter 1. The vi Text Editor
UNIX has a number of editors that can process the contents of text
files, whether those files contain data, source code, or sentences.
There are line editors, such as ed and ex, which display a line of the
file on the screen; and there are screen editors, such as vi and
emacs, which display a part of the file on your terminal screen. Text
editors based on the X Window System are also commonly
available, and are becoming increasing popular. Both GNU emacs
and its derivative xemacs provide multiple X windows; an
interesting alternative is the sam editor from Bell Labs. All but one
of the vi clones described in Part II of this book also provide X-
based interfaces.
vi is the most useful standard text editor on your system. (vi is
short for visual editor and is pronounced "vee-eye.") Unlike emacs,
it is available in nearly identical form on almost every UNIX system,
[1]
thus providing a kind of text-editing lingua franca. The same might
be said of ed and ex, but screen editors are generally much easier
to use. With a screen editor, you can scroll the page, move the
cursor, delete lines, insert characters, and more, while seeing the
results of your edits as you make them. Screen editors are very
popular, since they allow you to make changes as you read through
a file, like you would edit a printed copy, only faster.
[1] Actually, these days, GNU emacs is pretty much the universal version of emacs; the only problem is it
doesn't come standard with most commercial UNIX systems; you must retrieve and install it yourself.
To many beginners, vi looks unintuitive and cumbersome鈥攊nstead
of using special control keys for word processing functions and just
letting you type normally, it uses all of the regular keyboard keys
for issuing commands. When the keyboard keys are issuing
commands, vi is said to be in command mode. You must be in a
special insert mode before you can type actual text on the screen.
In addition, there seem to be so many commands.
Once you start learning, however, you realize that vi is well
designed. You need only a few keystrokes to tell vi to do complex
tasks. As you learn vi, you learn shortcuts that transfer more and
more of the editing work to the computer鈥攚here it belongs.
vi (like any text editor) is not a "what you see is what you get" word
processor. If you want to produce formatted documents, you must
type in codes that are used by another formatting program to
control the appearance of the printed copy. If you want to indent
several paragraphs, for instance, you put a code where the indent
begins and ends. Formatting codes allow you to experiment with or
[ 本帖最后由 projl 于 2008-6-12 16:59 编辑 ] |
|