If we need to, we can also start vi toedit multiple files. This is done like this:
Once we are editing, we can switch between files withfor the next file and for the previous one. Keep in mind that the file names do not wrap around. In other words, if we keep pressing and get to file3, doing it again does not wrap around and bring me to file1. If we know the name of the file, we can jump directly there, with the ex-mode edit command, as in
The ability to edit multiple files has another advantage. Do you remember those numbered and named buffers? They are assigned for a single instance of vi, not on a per-file basis. Therefore, you can delete or yank text from one file, switch to the next and then insert it. This is a crude but effective cut and paste mechanism between files.
If you switch to editing another file (usingor ), reload an original file (using or ), the contents of the deletion buffers are preserved so that you can cut and paste between files. The contents of all buffers are lost, however, when you quit vi.