Multi-file editing
Many times, we need to copy the contents of a file into the B file. If we use two vim windows to edit two files, the pasted content cannot cross the window.
Enter the following command to open multiple files in one window at the same time
vim file1, file2, file3
Use the command:
vi A.txt B.txt
In command mode input: Files to view the Open file list:
Command mode input:
- : N Edit Next file
- : N Edit Last File
- : Files lists all the files that are currently open by this vim
Multi-window editing
Described above is a window to open one or more files, Vim also provides multiple windows to open one or more files.
Sometimes, when a file is particularly large, such as 1000 rows, when looking at the data in the back, we need to compare with the previous data, when the multi-window is very useful.
Command mode:
- SP filename opens a new window, if there is a filename, indicates that a new file is opened in a new window, otherwise a new window displays the same file (synchronized display)
- The Vim window opened by VSP filename is arranged vertically;
- Cursor switching between windows
- Ctr + W + j (bottom arrow): Cursor switches to next window
- Ctr + W + k (UP ARROW): Cursor switches to previous window
Effects such as:
SP filename
VSP filename
: Set mouse=a makes the mouse active in Vim, you can use the mouse to move the cursor to drag the Vim window.
VIM Multi-file Multi-window function