Vi Editor, A Beginner's Guide

Why Vi Is More Or Less Useful, Or At Least Funny

by Rickard Andersson (rickard@softlab.se)
written 22 Jun 1994

This article is classified "Real"


If you happen to be a beginner with the vi editor, or if you have used vi
for a couple of years and just want to know what you have been doing, keep
on reading.  This is your chance to get a grip on the vi editor.

The vi (can be pronounced like the word vie, as in the sentence "vie do
you want to use it?") editor is a very powerful full-screen editor used
mainly in the presence of the Unix operative system.  If you feel that a
full-screen editor is to much to handle, the line editor "ed" might be a
more appropriate choice.  Some people (mostly degenerated or mutated
though) on the planet Earth are even, as the rumour tells it, using a text
editor named Emacs.  The rumour isn't capable of explaining why somebody
would be using Emacs.

For the real vi user that gets a nasty abstinence working with a graphic
text editor or word processor on a non-unix OS, there are some variants of
vi for, among others, the Mac OS.

If you have been playing an excellent adventure game called NetHack, you
will be used to the way vi users moves the insertion point in the text.
You will know that the key [ h ] is used to move one character to the left
and subsequently that the key [ l ] is used to move one character to the
right.  So, if you are an experienced NetHack player you could open the
text file you want to make changes to and imagine that the monsters are
attacking you.  By typing along just as if you where playing NetHack, your
text files could be transformed into a masterpiece of a text, maybe even
in eminence for a Nobel Price in literature.

To send new vi users in the right direction, some useful key combinations
are listed below:

          o Press the [ G ] key to go to the end of your text file.

          o Press the [ ~ ] key to alter between lowercase and uppercase of
            the current character in the text file.

          o To replace all occurrences of '42' by '68', just press:
            [ : ], [ 1 ], [ , ], [ $ ], [ s ], [ / ], [ 4 ], [ 2 ], [ / ],
            [ 6 ], [ 8 ], [ / ], [ g ], [ Return ].

          o To escape from the vi editor, the user has several choices: one
            is to press the [ Z ] key twice.  Another variant is to press
            the keys [ : ], [ q ], [ ! ] and [ Return ].

          o The [ . ] key is used when you want to repeat the last edit
            command over and over again.  It is one of the more powerful
            commands in the vi editor.

          o Press the [ ' ] key twice to move the insertion point to the
            last known position in the text file.

          o For the ultimate thrill, a vi user with a high distress level
            could try to press [ Caps Lock ] and then the keys forming his
            name.  Now you just have to watch things happening with your
            text file, in a nice and mostly harmless manner.


The best way to recognize a vi user is to listen for the well known sounds
"Ooops!," "Aha!" and "Finished, before my partner even have managed to load
the text file into Word!".

This is more or less everything you need to know to get started with vi.
And remember, using vi isn't more complicated than making a correct "awk"
or "sed" command.

Read more about vi in the sequel Vi Editor, A Less Beginner's Guide.

See also:
  • Unix Vi Editor, Case Study Of
  • Unix, Part 1
  • Vi Editor, A Less Beginner's Guide

  • Go to [Root page | Title list | Author list | Date list | Index]