vi editing  «Prev 

Switching between files within a vi session

1) By entering the UNIX command vi recipe quartet, you can edit both files within the same vi session
By entering the UNIX command vi recipe quartet, you can edit both files within the same vi session

2) vi displays the first file, recipe
vi displays the first file, recipe

3) To go to the next file, enter the :n command.
To go to the next file, enter the :n command.

4) Now you are in the quartet file, as confirmed by the status line.
Now you are in the quartet file, as confirmed by the status line.

5) If you try to use :n again, the message "No more files to edit." That is because quartet is the last file in the list, so there is no next file
If you try to use :n again, the message "No more files to edit." That is because quartet is the last file in the list, so there is no "next" file.

6) The :rew command starts the list over, rewinding to the first file. Rewinding is typically used with 3 or more files. In this case, with only two files, you also could enter :re#
The :rew command starts the list over, rewinding to the first file. Rewinding is typically used with 3 or more files. In this case, with only two files, you also could enter :re#

7) After rewinding the list, vi reports that there are 2 files to edit and that you are currently in the recipe file.
After rewinding the list, vi reports that there are 2 files to edit and that you are currently in the recipe file.

8) Now use the :q command to quit vi.
Now use the :q command to quit vi.

9) Instead of quitting, vi report that there is 1 more file to edit. To really quit vi, you must enter :q a second time
Instead of quitting, vi report that there is "1 more file to edit". To really quit vi, you must enter :q a second time.