Method 2:
Input in command line mode
6,9 Co 12
Copy the contents of lines 6th through 9th to the following line 12th.
Method 3:
Sometimes you don't want to struggle to see how many rows or large lines are copied, you can use labels instead
Move the cursor to the start line, enter the MA
Move the cursor to the end line, enter MB
Move the cursor to the pasted row, enter the MC
Then: ' A, ' B Co ' c changes the co into m and cuts it.
To delete multiple lines, you can use: 5, 9 de
GG to top G to end of page
Line number +g jumps to the specified line n+ the cursor moves down n rows N- cursor up n rows ctrl+g query current line information and current file information
Search and Replace commands
/pattern: Searches for pattern at the end of the file from the beginning of the cursor
? pattern: Searches for pattern from the beginning of the cursor to the top of the file
N: Repeat the last search command in the same direction
N: Repeats the last search command in the opposite direction
: s/p1/p2/g: Replaces all P1 in the current row with P2
: n1,n2s/p1/p2/g: All P1 in line N1 to N2 are replaced with P2
: g/p1/s//p2/g: Replace all P1 in the file with P2
----5. Edit 2 files Simultaneously, copy the text from one file and paste it into another file.
----VI file1 file2
----YY in the cursor at the file 1 copy the row
----: n Switch to File 2 (n=next)
----p Pastes the copied row at the cursor where the file 2 is located
----: n Switch back to file 1
Vim Common commands