z/OS UNIX System Services User's Guide
Previous topic | Next topic | Contents | Contact z/OS | Library | PDF


A simple vi session

z/OS UNIX System Services User's Guide
SA23-2279-00

This information shows you how to edit a simple text file. Try it to get the feel of using vi. You can edit the text file:
vi1.txt
which is supplied as part of the z/OS® shell. It is in the directory /samples. To do this, copy this file to current working directory:
cp /samples/vi1.txt vitest
Now, begin your vi session by typing:
vi vitest
vi clears the screen, then displays the contents of the file. , vi also displays:
"vitest" 30 lines, 668 characters
This tells the name of the file being edited and how big it is.
The cursor is positioned at the beginning of the file. These keys let you position the cursor anywhere on any line in the file:
Table 1. vi editor: Positioning the cursor
To move the cursor: Press
Down a line j or (the Down arrow key)
Up a line k or (the Up arrow key)
Left along a line h or (the Left arrow key)
Right along a line l or (the Right arrow key)
Note: The arrow keys do not work on all terminals.

To experiment a bit more, move the cursor to the beginning of the first line in the file, then press 5 followed by . You do not see the 5 displayed anywhere—but when you press , you see the cursor move five characters to the right. As a general rule, when you type a number followed by an action, vi repeats the action that number of times.

By the way, ask yourself if you are in Insert Mode or Command Mode. You must be in Command Mode because the characters you type (for example, the 5) do not appear on the screen. When you start a vi session, you always begin in Command Mode.

Go to the previous page Go to the next page




Copyright IBM Corporation 1990, 2014