1. The most basic copy and paste
1. Move the cursor to the beginning of the text to be copied, and press v
to enter the visual mode.
2. Move the cursor to the end of the text to be copied, press y to copy, and exit Visual mode.
3. Move the cursor to the paste place and press p
Paste.
2. Delete multiple lines
dd deletes a line
ndd deletes n lines starting with the current line
dw deletes a character starting with the current character
ndw deletes n characters starting with the current character
d$, D deletes a line of characters starting with the current character
d) deletes until the next sentence Start
d} delete to the beginning of the next paragraph
d carriage return to delete 2 lines
3. Copy multiple lines
For example: copy the data from row 20 to row 30 to row 10
3.1 Method 1 (strongly recommended)
: 20, 30 copy 10 or: 20, 30 co 10
from this can have:
: 20, 30 move 10 or: 20, 30 m 10
3.2 Method 2
Move the cursor to the end line, ma
cursor to the start line, enter y'a
to move the cursor to the line to be copied, enter p, and enter uppercase P to copy before the line
3.3 Method 3
Move the cursor to the 9th line shift + v,
then move the cursor to the 15th line ctrl + c,
and then kill the cursor to the 16th line p mysql
3.4 Method 4
Move the cursor to the start line, enter ma
to move the cursor to the end line, enter mb
to move the cursor to the paste line, enter mc
and then enter: 'a,'b, co 'c change co to m to cut if you want to delete
multiple lines , then enter: 'a,'b de
vim set automatic indentation: set smartindent
vim set display line number: set number or set nu
4. How to select and copy all in Vim
Delete all: after pressing esc, then dG
Copy all: after pressing esc, then ggyG
Select all highlight: press esc, then ggvG or ggVG
Five, how vim interacts with the clipboard (copy the contents of vim)
Use "*y to copy in vim, and then use ctrl+v to paste in the application. From the application to vim, use ctrl+c to copy in the application, and use shift+insert to paste
in vim . For example:
"*yy copy one line
"*y2w copy two words
...
The principle of realization is:
" Indicates the use of registers
" * Indicates the use of the current selection area
ctrl+insert to copy, shift+insert to paste.