Java Reference
In-Depth Information
2.2
E YE TO E YE WITH VI
Java programs consist of Java classes. Java classes are text files with Java state-
ments and expressions. In order to write a Java program, then, you need to be
able to enter text into a file. Sounds simple enough.
With Linux and its GNU tools, you have an amazing array of choices for
how to do this. Some are GUI tools not unlike simple word processors. Others,
like vi and Emacs, predate GUI tools, but provide much the same capability
without the luxury (or annoyance) of a mouse or menus. 1
The editor named vi (pronounced as you would spell it: “vee-eye”) is one
of the most enduring tools in Linux. Its popularity comes from a combination
of power and ubiquity—you can find it on virtually every release of UNIX and
Linux since 1985. But it is a powerful editor that can do a lot with only a few
keystrokes.
There are actually several variants of vi from which to choose. Each is
someone's attempt to go one better on vi , but all retain the same basic syntax
and what you learn here will work equally well on any of the vi clones. You can
choose among
elvis
nvi
vim
Start up vi by typing the command name at a shell prompt, followed by
the name of the file(s) that you want to edit:
$ vi Account.java
Keep in mind that vi was developed in the days of character-only video
screens. Keyboards didn't always have arrow keys or other special characters,
which have since been (largely) standardized by the advent of the IBM PC. In
that situation, the authors of vi had only the alphabetic characters to use for all
1. We realize that vi is famous for being difficult to learn and nonintuitive. The UI design of
vi dates back to earliest cursor-addressable display terminals. User interface design has come a
long way since then. The vi UI does indeed show its age. But the program refuses to die. Why?
Because while simple GUI editors make the easy stuff easy, vi makes the hard stuff easy. You
can fall back on pico or kate or other GUI editors if you want, but bear with us. Mastering vi
really does pay off.
Search WWH ::




Custom Search