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


Editing several files

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

In a typical vi session, you may want to edit several files. When you have finished editing one file, you must first save your text in that file. Once you have saved your changes, you can start editing a different file by typing:
:edit newfilename
and then press <Enter>. This will clear out the text you have been editing and set things up so you can edit the new file. If the file already exists, its current contents will be read in.
Here's a trick to remember when you want to edit a number of files. If you start vi with a command line of the form
vi file1 file2 file3 ...
you can edit several files one after the other. After you have finished editing a file and saved it, you can move among files using the following commands:
Command
Action
:n
Edits the next file in the list of files.
:n!
Edits the next file in the list of files and discards the changes made to the current file.
:n filenames
Specifies a new list of files to be edited.
It may be particularly useful to use wildcard characters on the vi command line, as in
vi *.c
This is expanded to a list of all the files under the current catalog that have the .c extension.

Go to the previous page Go to the next page




Copyright IBM Corporation 1990, 2014