VI --- Visual Editor


Table of Contents


Overview

What is VI?

VI is a full-screen text editor available on all UNIX systems. Take a look at A Naive Introduction to VI to get started. And if you just need to know how to get out of VI, then this Quick Introduction might be more appropriate.

Why use VI?

When not to use VI


Examples

Anything you do with vi is by definition cool stuff.

Cool Stuff

Indenting incoming mail

You've seen those > signs that people like to use before the lines of an included mail message. Here is a one-liner that does it in vi.
:1,$s/^/>/
If you want to prepend > only upto the current line, replace the "$" with a ".". If you want a space after the > sign, you should replace the ">" with a "> ". If your mailer (like /usr/ucb/mail) prepends included mail messages with a tab, then replace "^" with "^[tab]".

Changing input upto a comma

Say you want to change all the text in a sentence upto a comma. Rather than deleting this text and then inserting new text, try the following:
cf,[new input][ESC]
This does the job in one shot. You can replace the "," with any other letter.

Editing multiple files in VI

Although VI does not allow multiple windows, editing multiple files is not a problem. Start VI up with: "vi file1 file2..." and make sure that "aw" is set (either in .exrc or with :set aw inside VI). Move to a new file by issuing a :n filename. Your place will be kept in the old file as you move to the new file. To yank from one file and paste into another use named buffers. For more details, take a look at this article.

Key Bindings

Using key-bindings can make your VI sessions even faster and more convenient. Here are some articles that discuss these advanced features:

Misc Cool Stuff

Remember to look at named buffers and filtering text through UNIX filters. Also become familiar with the ex commands that underly VI. A list of other cool vi tricks.

References

Introductory

Advanced

Books:

VASC Contact

Rahul Sukthankar rahuls@ri.cmu.edu

History


Rahul Sukthankar (rahuls@ri.cmu.edu)
Last Updated: Sep 22, 1996 by rahuls@postbox.ius.cs.cmu.edu
This page has been accessed [count] times.