Vi 101 - Let's Tango! (
Page 4 of 9 )
Now that you know how to
insert text, it's time to teach you the second most confusing thing about vi -
moving around within the document. In order to gain the maximum benefit from
this lesson, I suggest you either open an existing document, or create a new one
and enter a few lines of text into it. Make sure that you're in command mode by
hitting
<ESC>
a few times when you're done.
Vi's movement keys are
h
= left
j = down
k = up
l = right
On some UNIX consoles, it may
also be possible to use the cursor keys to accomplish movement within the
document; however, I suggest that you take a few moments to memorize the list
above instead, as cursor key movements can sometimes get lost over telnet
connections, while the standard vi keys above will work in any
situation.
Care to move between words? Try
w
to move one word forward, or
b
to move one back.
To move between paragraphs, try
{
and
}
while moving between sentences requires careful use of
(
and
)
If you need to move to a specific line in your docume nt - line 568,
for example - try this
:568
To move to the beginning of the file, type
gg
while the end of the file is just a
G [that's shift-G]
away. And vi also has an equivalent for the "Page-Up" and "Page-Down"
commands common in other text editors; try
^F [that's Ctrl-F]
to move one page forward, and
^B [that's Ctrl-B]
to move one page back.
To find out your exact position in the
document [kinda like GPS, but not as cool!], try
^G [that's Ctrl-G]
Of course, these aren't the only motion keys - there are quite a few
more, but I'm afraid that you'll only hear about them in "Vi 202". For the
moment, these should be sufficient for our next exercise, in which you'll be
doing the tango with your keyboard. Come on, you know how this goes - two steps
left, one step right, three steps back, and shake it all about...
This article copyright 2000. All rights
reserved.