Java Reference
In-Depth Information
of their commands . . . and did they make good use of those keys! Virtually
every letter is used, both lower and upper case, to mean something unique in
vi
. But don't be put off by the large number of commands to learn; they fit
some patterns that will make it easy for you to become proficient in a short
time by learning a few commands and applying the patterns.
NOTE
If you really can't bear to part with your mouse and menus, try
gvim
. We haven't
used it, but we hear that it has support for mice to help with cut and paste and
the like. After you learn
vi
and get a little practice, though, you may find that
you're never reaching for your mouse any more when you edit.
There are three modes to
vi
: the regular
vi mode
, some extended
commands in the
ex mode
, and the
input mode
.
The simplest mode is the input mode. In input mode, every character you
type becomes part of the text of the file. It's how you enter the bulk of the text
for your Java programs. But
vi
doesn't start up in input mode; you have to “get
into” input mode, and then get back out. Once out, you can use other
vi
commands to save the text and exit
vi
. More about those in a bit.
NOTE
Get out of input mode by pressing the Escape key. You can press it more than
once, too, just to be sure that you are no longer in input mode. If you are no
longer in input mode and you press escape, it will beep at you—with an audible
or visual notification, depending on how your terminal window is set to respond.
In both
vim
and
elvis
(two popular
vi
clones) there is a status line at the
bottom of the window that will show if you are in input mode. In
vim
, look
in the lower left and
elvis
, the lower right. When in input mode, you will see
a status word displayed like
insert
or
replace
.
In the vi mode, the default mode that you start in, all the keystrokes are
interpreted as commands to the editor. They are
not
displayed as characters. So
when we describe a command, such as
dt;
, you can type those three characters
but will not see those characters on your screen. Instead you will see some ac-
tion taken by
vi
—in this case it will delete text from your cursor up to the first
semicolon on that line, if any (otherwise it will just beep).