TechTutorials - Free Computer Tutorials  







Using the VI Text Editor 
 


Added: 08/01/2002, Hits: 3,787, Rating: 0, Comments: 0, Votes: 0
Add To Favorites | Comment on this article
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
kLine up
jLine down
lright space
hLeft space

The arrow keys will also allow you to move around in VI.
Delete commands
dwDelete word
ddDelete line
DDelete rest of line
xDelete character under cursor
XDelete character before cursor

Change commands
cwChange word
ccChange line
CRest of line
sChange character under cursor
rReplace character


Insert commands
aInsert text after cursor
AInsert text at end of line
iInsert text before cursor
IInsert text at beginning of line
oOpen new line below
OOpen new line above

Cut and paste commands
ywYank word
yyYank line
pPastes after cursor
PPastes before cursor

Saving and quitting
:qQuit - 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.

Good Luck!





Comments (0)

Be the first to comment on this article


Related Items








7 Seconds Resources, Inc.




IT Showcase