The very famous one is supplied by default Vi editor (visual editor) together with Linux-Unix operating system. You can learn basic operations about VI editor in this article… However, along with the basic commands, we can open several files and switch between them in the VI editor.
How to open multiple files and switch between them in the VI editor
Basically you know that in order to open a file in the VI editor you need to use command VIfollowed by the filename. To open multiple files and switch between them in the VI editor use below syntax.
#vi file1 file2 fileN
Let’s see an example, you have two files in the “/ tmp / grayex” folder
[[email protected] andreyex]# pwd /tmp/andreyex [[email protected] andreyex]# ls -lrt total 8 -rw-r--r--. 1 root root 25 Jun 27 10:35 1.txt -rw-r--r--. 1 root root 27 Jun 27 10:35 2.txt [[email protected] andreyex]#
Now let’s try to open these files using the following command:
# vi 1.txt 2.txt
In case you want to open files in bookmarks, try the same command with the -p option:
# vi -p 1.txt 2.txt
This command will open files “1.txt” and “2.txt” in bookmarks.
How to switch between files:
Now, to go to the next file to use, enter the option below in command line mode.
Now, in order to revert to the previous file or switch it back to the previous use of the file, enter the option below in the VI command mode.
How to open multiple files in a split window:
There is another way to open multiple files and switch between them in the VI editor. You can also open multiple files in a split window with the command below.
# vi -o 1.txt 2.txt
How to switch between them
Now, to switch between them, follow the following command in VI: