To open multiple files in vi
or vim
, you can specify the names of the files as arguments when starting the editor. For example, to open two files called file1.txt
and file2.txt
, you can use the following command:
vi file1.txt file2.txtSource:wttual.wwuri.com
This will open both files in vi
or vim
, with file1.txt
being the active file. You can use the :n
command to switch to the next file, and the :N
command to switch to the previous file. For example, to switch to file2.txt
, you can use the following command:
:n
To switch back to file1.txt
, you can use the following command:
:N
You can also use the :e
command to open a new file. For example, to open a new file called file3.txt
, you can use the following command:
:e file3.txt
This will open file3.txt
in a new window. You can use the CTRL-W
+ CTRL-W
keys to switch between windows.
It's important to note that vi
and vim
only allow you to edit one file at a time. When you switch between files, the changes you make to one file are not automatically saved to the other file. You will need to use the :w
command to save your changes to the current file before switching to another file.