|
|
To edit more than one file in a session, start vi
giving it a list of files, as follows:
vi file1 file2 file3 ...
vi only edits one file at a time, but you can move forward through the list by typing :n (next) in command mode, or go to a specific file by typing :e filename (short for :edit filename) in command mode. Note that you cannot edit the next file if you have made changes to the current one, unless you save the current file with :w or override vi by using the :n! (unconditional next file) command. To return to editing the first in the list of files, type :rew (short for :rewind).
Note that if you switch files without saving the contents of the last one you edited you will lose any changes you have made: see ``Saving files and quitting vi'' for how to save the current file.