VI --- Visual Editor
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?
- It's there on all UNIX systems; works on any terminal.
- If you know VI, you know much of awk, sed, grep
(and nethack) for free.
- Small, fast, dependable but very powerful (especially for touch typists).
- Consistent and tiny command set -- works on all keyboards.
- Why people on the net love VI.
When not to use VI
- When you are writing LISP code (lisp mode is inferior to Emacs).
- When you are editing binaries (VI chokes on huge lines).
- When you have forgotten the commands (no online help). Keep the
VI reference handy!
Anything you do with vi is by definition 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:
- Article on which keys are free in VI.
- Article on switching between sets of key-bindings.
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.
Introductory
Advanced
Books:
- Tutorial and reference: "The Ultimate Guide to the VI and EX Text editors"
by the Hewlett-Packard Co.; Benjamin/Cummings Publishing Co. (1990)
Rahul Sukthankar
rahuls@ri.cmu.edu
- October 17, 1994: Created by Rahul Sukthankar (rahuls@ri.cmu.edu)
- March 2, 1995: Minor changes.
- July 10, 1995: Added vi-maze macro.
- May 16, 1996: Added link to FAQ and VI Lovers Home Page.
- Sep 22, 1996: Minor changes.
Rahul Sukthankar
(rahuls@ri.cmu.edu)
Last Updated: Sep 22, 1996 by rahuls@postbox.ius.cs.cmu.edu
This page has been accessed
times.