VI commands for opening and editing multiple files can be divided into two situations:
1. open multiple files in the same window:
VIFile1 file2 file3
: NSwitch to the next file (n = NEXT)
: NSwitch to the previous file
2. open multiple files in different windows:
If you have already opened a file,
Then, in the command input state of VI, enter: SPPath and file name of another file,
In this way, you can open multiple files in a window.
Or useVI-oFile1 file2 file3. .. multiple files are opened simultaneously in a split screen window.
You can press Ctrl + twiceWOrCTRL + WThen pressUp/down keysSwitch between upper and lower windows. 2. Split windows to edit multiple files
* Use VI to open a file, for example, VI actinia_proenrule.sh.
* Open another file in the split window.
In command line mode, enter another SP file to split the file horizontally and open the second file. If you want to split the file vertically, you can use the VSP file name.
Note: sp = Split, VSP = vsplit. the preceding statement is a simple statement supported by VI, and V is actually vertical. We can see the meaning of the command change. In addition, Vi not only supports two files, more files can be displayed and edited in a large window at the same time, and the two files simultaneously opened are the same file.
* Window Switching
You can press Ctrl + twice to switch between files.
Previously, I thought it was inconvenient to edit multiple VI Documents. Now I have some contact with minibufexplorer and found that it is not very comfortable. It is better to use ls.
: Ls displays all open documents
: Switch XN to the x document below
N Ctrl + 6: switch to the nth Buffer
CTRL + 6 or: E # return to the previous editing File
Split screen
: New XXX
CTRL + w s split-screen display of the current document content
CTRL + w Q close the split screen
CTRL + w o only displays the current split screen content
CTRL + w j k select up/down split screen
I personally think the most useful command is Ctrl + W to quickly switch between the two screens on the split screen.
I haven't written the following ~ After reading this article, I think these are pretty good.
: N1, N2 Co N3: copy the content from line N1 to line N2 to line N3.
: N1, N2 M N3: Move the content from line N1 to line N2 to line N3
: N1, N2 D: Delete content from line N1 to line N2
: N1, N2 W! Command: The content from line N1 to line N2 in the file is used as the command input and executed,
If N1, N2 is not specified, the entire file is used as the command input.
The advantage of method 2 is that you can directly use the nyy and PP commands to copy and paste files in each window, which is more convenient. There are two possible cases:
1. open multiple files in the same window:
VIFile1 file2 file3
: NSwitch to the next file (n = NEXT)
: NSwitch to the previous file
2. open multiple files in different windows:
If you have already opened a file,
Then, in the command input state of VI, enter: SPPath and file name of another file,
In this way, you can open multiple files in a window.
Or useVI-oFile1 file2 file3. .. multiple files are opened simultaneously in a split screen window.
You can press Ctrl + twiceWOrCTRL + WThen pressUp/down keysSwitch between upper and lower windows. 2. Split windows to edit multiple files
* Use VI to open a file, for example, VI actinia_proenrule.sh.
* Open another file in the split window.
In command line mode, enter another SP file to split the file horizontally and open the second file. If you want to split the file vertically, you can use the VSP file name.
Note: sp = Split, VSP = vsplit. the preceding statement is a simple statement supported by VI, and V is actually vertical. We can see the meaning of the command change. In addition, Vi not only supports two files, more files can be displayed and edited in a large window at the same time, and the two files simultaneously opened are the same file.
* Window Switching
You can press Ctrl + twice to switch between files.
Previously, I thought it was inconvenient to edit multiple VI Documents. Now I have some contact with minibufexplorer and found that it is not very comfortable. It is better to use ls.
: Ls displays all open documents
: Switch XN to the x document below
N Ctrl + 6: switch to the nth Buffer
CTRL + 6 or: E # return to the previous editing File
Split screen
: New XXX
CTRL + w s split-screen display of the current document content
CTRL + w Q close the split screen
CTRL + w o only displays the current split screen content
CTRL + w j k select up/down split screen
I personally think the most useful command is Ctrl + W to quickly switch between the two screens on the split screen.
I haven't written the following ~ After reading this article, I think these are pretty good.
: N1, N2 Co N3: copy the content from line N1 to line N2 to line N3.
: N1, N2 M N3: Move the content from line N1 to line N2 to line N3
: N1, N2 D: Delete content from line N1 to line N2
: N1, N2 W! Command: The content from line N1 to line N2 in the file is used as the command input and executed,
If N1, N2 is not specified, the entire file is used as the command input.
The advantage of method 2 is that you can directly use the nyy and PP commands to copy and paste files in each window, which is more convenient.