Vi is probably the most powerful text editor for *NIX, but if you have ever tried to use it, you probably walked away frustrated. This article walks through all the capabilities and features of Vi - from the basics, such as saving and quitting, to the more advanced topics of searching for strings.
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
a few times when you're done.
Vi's movement keys are
= 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
to move one word forward, or
to move one back.
To move between paragraphs, try
while moving between sentences requires careful use of
If you need to move to a specific line in your docume nt - line 568,
for example - try this
To move to the beginning of the file, type
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 Melonfire 2000. All rights reserved.