VI sucks! Use NANO the whiny baby editor Swamp likes! Don't use Emacs either. The Emacs people are almost as annoying as VI people. They have some sort of sick war going on as to which editor is better.
Use NANO!!!!! Better yet use a X editor with mouse support and move into the 1980's.
If you need to write code do it with something else please. VI isn't a compiler people! Their are lots of open source coding environments available for X.
Every now and then you will need a console editor like VI to edit things like crontab or during a terminal session. Use NANO instead! Instruction on how to change the default editor are here. Yes VI is the wondrous cross platform keys are always the same blah dee blah... YOU CAN'T USE THE UP AND DOWN ARROW KEYS TO NAVIGATE!!!! Its just silly damn it! Keep reading if your still interested in VI you sick puppy.

Vi (pronounce: ``vee eye'', not ``six'', not ``vye'') is an editor. An editor is a program to edit files. Duh!.

Although other stories exist, the true one tells that Vi was originally written by Bill Joy in 1976. Bill took the sources of ed and ex, two horrendous programs for Unix that try to enable a human being to edit files, and created Vi. A truly remarkable, and somewhat paradoxical, event.

People got attached to Vi, and eventually it got included in System V. From there on history has covered its traces and now Vi has evolved in many different versions for many, many platforms. The basic concept of Vi, however, has not changed over the years.

Should I use Vi? From the VI lovers homepage<-- Sick people!
Which editor to use is mainly a matter of taste, style, and needs. Big chance that Vi is OK for---at least---the last one.

The long story is that, even though Vi is somewhat awkward to use at first, it enables fast, simple, and effective editing once you get the hang of it. A key concept in Vi is combining a certain action (delete, copy to buffer, capitalize, etc.) with a movement (go to line 25, go to end of document, go to next occurrence of ``foo,'' go to 2nd occurrence of character ``x'' in this line, etc.). The action is performed on all lines or characters between the current cursor position and the destination cursor position. Vi is extremely powerful in moving around within (or between) files---Vim in particular is excellent. You can jump to a specific line, to the line where you were before jumping to the current line, to the line in the middle of the screen, to the line where you just changed ``foo'' into ``bar,'' etc. You'll never have to mess with arrow keys to move around within a file. Finally, I observe that an effective Vi user simply edits files faster than Emacs people. Last but not least, you don't need a third hand (or nose) to type impossible key combinations. Don't get me wrong: Emacs is a great operating system---it lacks a good editor, though.

Vi has its dark sides, too. The biggest one is the need to step back before leaping forward when you are new to Vi. You cannot use Vi properly before knowing at least a handful of commands. This makes the threshold rather high. Vi doesn't get fast before you know 25 commands or so, and you won't be the cool dude(tte) before you know even more. Note that this is also true for Emacs. However, Emacs is much easier to use as a newbie.

Rather confusing to new users is the empty screen that stares at them when Vi starts and not being able to simply start typing.

There is no conclusion. If you are a Windows user and you are forced to work under Unix for a week: don't learn Vi. However, if you need a good, multi-purpose editor, then Vi is a very good, highly recommended choice (but not by Swamp). Invest some time and learn Vi. There are many good links on this page to get you started.

Vi survival guide from the Newbie Linux Manual

Vi is the popular text editor guaranteed to feature on all Linux and Unix distributions, and is ideal for quickly editing configuration files from the command-line if your a freak from the 1970's who refuses to evolve.

There are two ways to start Vi:

  1. vi
    Open Vi with a blank unnamed document.
  2. vi filename
    Either begin editing a blank named document or open the file for editing.

Vi has 3 modes:

  1. Command mode: Where the majority of the trickery goes on.
  2. Insert mode: Where the majority of the typing occurs.
  3. Replace mode: Like Insert mode, only text is overwritten.

Vi begins in Command mode.

Insert/Replace mode

Type away as you would in any text editor.

Command mode

The following displays the most useful commands you can enter in Command mode to perform a wide assortment of tasks. Note that all commands are case-sensitive.

Save

:w Write an already named file to disk.
:w filename Required to save an unnamed document, or save a document with a new filename.
:w! filename Required to overwrite an existing file (other than the one you're editing).
 

Quit

:q Quit Vi, but only if document has not been modified.
:q! Quit Vi without saving document.
:wq Save document and quit Vi.
 

Open

:e filename Either open a file for editing, or begin a new, named document.
:r filename Add contents of file filename between current line and next line.
 
Everything that follows, happens at the cursor. Current line means, "the line the cursor's on". Keys are indicated inside square brackets. 'n' represents a number determined by you.
 

Move

n[cursor key] Move cursor that amount in that direction e.g. 19[Down] would move cursor down 19 lines..

[PageUp] Move up 1 page. Precede with a number to move up that many pages.
[PageDn] Move down 1 page. Precede with a number to move down that many pages.

gg Move to start of document.
G Move to end of document.
:n Move to start of a specific line.

b Move to beginning of current word, or to previous punctuation mark.
nb Perform b, n times.
e Move to end of current word, or to next punctuation mark.
ne Perform e, n times.

0   (zero) Move to start of current line.
$ Move to end of current line.

) Move to start of next line.
( Move to start of previous line.
 

Undo and redo

u Undo.
[Ctrl]r Redo.
 

Delete (cut)

dd Delete (cut) current line.
ndd Delete (cut) current line plus the n-1 lines below.
x or [Del] Delete (cut) current character.
 

Yank (copy) and paste

yy or Y Yank (copy) current line.
nyy or nY Yank (copy) current line and n-1 lines below.

p Paste text between current line and next line.
np Paste text between current line and next line, n times.
P Paste text between current line and previous line.
nP Paste text between current line and previous line, n times.
 

Search

/text Find the next instance of text from the cursor, where text is the string you're looking for. If nothing is found then Vi will wrap from the start of the document, back to the cursor.
?text The same as above but search direction is reversed.
n Next occurence (in either direction).
N Previous occurence.
 

Replace

:s/old/new Replace next instance of old, with new. (No document wrap occurs.)
:s/old/new/g Replace all instances of old, with new.
rcharacter Replace current character with character.
nrcharacter Replace current character plus the next n-1 characters with character.
 

Miscellaneous

J Join the line below, with the current line.
:help Display online help.