VI is a text editor that is available on all UNIX machines. It is archaic and difficult to use which is why this paper is here. Most of you MCSEs will never have to deal with this application, but if you ever do, you find that it is not intuitive enough to simply "figure out". This tutorial is not intended to explain every mode and feature of VI, but rather give you enough information to get around and get your work done.
Modes:
Before we get started, you will need to know how to open a file with VI. This is the easy part. You simply type, "vi [filename]" assuming that you are in the directory where the file lives. If not, you can also specify the path to the file in the command. If you attempt to open a file that doesn't exist, a new file will be created. VI has 3 different editing modes, however, for the purposes of this document you will only need to learn 2 of them - They are command mode and text(insert) mode. Command mode is the default mode that you will be in when you launch VI. Any of the following keys will get you into text mode: a, i, o, c, s, A, I, O, C, S - More on what these mean later. Once in text mode, the ESC key will get you back to command mode.
Commands:
Please note that VI commands are case sensitive.
Movement commands
k
Line up
j
Line down
l
right space
h
Left space
The arrow keys will also allow you to move around in VI.
Delete commands
dw
Delete word
dd
Delete line
D
Delete rest of line
x
Delete character under cursor
X
Delete character before cursor
Change commands
cw
Change word
cc
Change line
C
Rest of line
s
Change character under cursor
r
Replace character
Insert commands
a
Insert text after cursor
A
Insert text at end of line
i
Insert text before cursor
I
Insert text at beginning of line
o
Open new line below
O
Open new line above
Cut and paste commands
yw
Yank word
yy
Yank line
p
Pastes after cursor
P
Pastes before cursor
Saving and quitting
:q
Quit - if changes have been made you will be prompted to save or not.
:q!
Quit and don't save
:wq!
Quit and save changes
This should be enough to get you going. You will most likely only need to use VI for simple tasks such as editing a hosts file and the information presented here should be adequate for this type of task.