User:Spoonbender/Temp/II.doc

'''II. Starting vi'''

You could start a vi session with an already existing file or with a new file from scratch.

Syntax:

vi [filename]

Examples:

$ vi /etc/hosts

192.168.250.1steve

192.168.250.2mark

192.168.250.3big_bert

192.168.250.4little_john

jamie

~

~

~

~

This vi session was invoked to edit an already existing file /etc/hosts. Note that this file would be ready for modification only if you have entered the input mode.

$ vi newfile

~

~

~

~

~

~

~

This vi session was invoked to create a new file newfile. Notice that the unused spaces are marked with tildes ( ~ ). You would need to enter the input mode to insert text in the file

It is relatively easy to invoke a vi session. You simply need to key in the command vi followed by the name of the file you wish to edit. If the file does not exist, it will create a temporary file for you to edit. If the file already exists, then it will display the contents of that file.

When a vi session is started, whether the file exists or not, vi puts it in memory into a temporary file we call the edit buffer. This file is not necessarily written into the disk drive. Instead, it stays in memory until the user issues a write command. This is very useful when modifying existing files. The buffer is not written to the disk until the user is sure of his modifications. If the user changes his mind or have noticed irregularity in his modification, he could discard the changes any time and the original file would not, in any way be affected.

If a new file was invoked using the vi session, you would notice each line in the new file are filled with tildes ( ~ ) running down from the left column. These indicate that those lines in the file are still vacant and it is up to the user if he wants to add text to it.