Vim Multifile Edit

Source: Internet
Author: User
1 screen
A install screen through ports
B $ screen
C $ vi file1.c
D CTRL + a c (hold down CTRL and a at the same time, release and then click c, the same as below) to create a new window
E $ vi file2.c
F move the cursor to the Starting Point
G CTRL + a [enter copy mode
H. Click the space sign start point.
I select a range through hjkl
J. Click the space sign to end.
K CTRL + a p to enter the previous window
L click I to enter insert mode
M CTRL + a] Insert Current Position 2 insert
A $ vi file1.c
B. move the cursor to the insert point.
C: r file2.c
Suitable for inserting one file into another 3 window
A $ vi file1.c
B: split file2.c
C CTRL + w j/k switch between upper and lower windows
You can ~ /. Add the following two lines to vimrc:
Map <C-J> <C-W> j
Map <C-K> <C-W> k
In this way, you can use CTRL + j/k to switch between upper and lower windows.
You can also use the following two lines:
Map <C-J> <C-W> j <C-W> _
Map <C-K> <C-W> K <C-W> _
Implement Ctrl + J/K to switch the window and make the current window fully occupied by the screen 4 buffer
A open multiple files through Vim (you can use ctags or csags)
B: ls to view the currently opened buffer (file)
C: B num switch file (where num is the number in the buffer List)
The available Commands include:
: BN -- next buffer in the buffer list
: BP -- previous buffer in the buffer list
: B # -- previous buffer you was in
You can ~ /. Add the following three lines to vimrc:
Map <right>: BN <CR>
Map <left>: BP <CR>
Map <space>: B # <CR>
Enables the left and right direction keys to switch to the upper or next buffer, and switches between two buffers by space.
Typical application scenarios: Open the c file and the H file at the same time, and then use spaces to switch between the 5 mark
A $ VI file1.c
B. move the cursor to your position and click mr.
C: E file2.c
D move the cursor to the position you are following and click mW
E. You can switch between files through 'r/'W.
M [A-Z]: lowercase marks, valid within one file
M [A-Z]: uppercase marks, also called file marks, valid between files
This method is suitable for reading the source code and editing three or more files. It is in the same vim. You can use yy, yw, y'a, dd, copy and paste dw, d' a, and p
In addition, when you exit a modified but unsaved file, vim prompts you to save the file. You can run the following command:
: Set autowrite
It is automatically saved.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.