The vi Editor
(vi
means "visual")
(vim
means "vi improved")
Much of this page was
written with either the vi or vim editor. Some
was written with the Mozilla or Netscape Composer.
What about vim?
We don't have it here yet,
but we
will soon. It is a much enhanced version of vi. Catch a
glimpse of some of the difference between vi & vim HERE.
The vim homepage is HERE.
A six kilobyte
explanation of vim is HERE.
For another web based vi tutorial from
Purdue University, look HERE.
For a really extensive
look at vi
from U. Cal. Berkeley (Berkeley
Software Division) look HERE.
For a fairly extensive
printable vi
tutorial, look HERE.
This is an Adobe .pdf file from the Rice University IT
Department.
For
a shorter much more basic introduction to vi, continue
here.
First things first.
Do you have a file in your home
directory
named ".exrc"? The user in the examples in this HowTo is named dork.
His
home directory is /home/dork. Looking in the listing of his home
directory,
dork sees no .exrc file. Note that he gave the command:
ls -la (See Fig. 1)

Fig. 1
The -la argument is
for a long list and to
include
all
files, even the "hidden" ones. Since dork was created just for this
exercise,
there are no files in his home directory. The .exrc file will
contain
some
settings that are very helpful in the use of vi. Every time vi is
called
it looks in your home directory for the .exrc file. If
it's there and
has
commands in it, it changes the way vi will act
while you're using it.
In
other words, it's customizable. What a concept! Time to create the
.exrc file and fill
it with things to make life easier.
vi .exrc<return>

Fig. 2
Now we're in the file
.exrc and we see that it is
indeed
a [New file]. As you can see, Line 1 is waiting for something, and the
we'd like to see that it actually is Line 1. See Fig. 3.

Fig. 3
Type the letter a.
Nothing will
appear to
happen, but the file is now prepared to have something added to it. (a
for
add). Type in
set number<esc>
The <esc>
is the escape key. This
takes
you out of the "add" mode. See Fig. 4. Your .exrc file should look like
Fig.4.

Fig. 4
Now we're ready to
save and exit the .exrc file. This
is
done by typing a colon, which will show up at the bottom of the screen.
This puts you into what is known as the command mode.
The
command you will now type in is wq. This means write
and quit. There is a reason for this. See Fig. 5.

Fig. 5
Entering a <return>
now will save
and
exit the file, and return you to the command line. To quit the
vi editor without saving you can enter :q!,
but
not
this time. Now enter (again) vi .exrc, to get you back
into the editing of the .exrc file as
shown in Fig. 6.

Fig. 6
As can be seen in
Fig.7 there is a "1" next to the
beginning
of Line #1. This is what the set number command
accomplishes.
When vi was invoked, vi looks for the .exrc
file to see how to modify its standard behavior. There are dozens of set
commands. They can be seen by typing (while vi-ing a file) :set
all<return>.
Many of them are intuitive but some are not. See Fig. 8 for an
incomplete
list of set commands for the .exrc file. At
the command line try man vi for a
very esoteric description of vi.

Fig. 7
The commands as seen
in Fig. 8 that start with "no"
usually have
counterparts
without the "no". For example, nonovice has the
counterpart
command novice, which is not a bad thing for new vi
users.
A much more inclusive explanation of the set command is HERE.

Fig. 8
Fig. 9 shows a
recommended "starter" .exrc file. This
can always
be
altered by you in the future.

Fig. 9
There is the possibly
you may have encountered some
problems
in this brief introduction to vi but hopefully the next
section of this HowTo will go into some of these possible difficulties
and how to overcome or get around them. The next part of
the vi HowTo can be found here in Part
2.
(BACK) to
where
you were