This way you don’t need to set anything at all when pasting in insert mode, and there is no need for alternative key combinations.
Supplement: I forgot to mention the side effects of this method. It will cause the options such as 'autoindent' and 'smartindent' in insert mode to be reset, so it is equivalent to canceling automatic indentation, so please use it selectively.
You can also do this “+p to paste;
For convenience, I made a mapping nnoremap <leader>p "+p;
Type :reg to see what's held in the register;
Select some characters first, and then ”+y you can copy the selected part to the system clipboard;
Reference Accessing the system clipboard How to use vim registers?
Before pasting:
:set paste
Finished pasting:
:set nopaste
Another great method:
:r! cat
Then use
shift+insert
or other way to paste the code, then
ctrl+d
Complete input.
Source
I always use another better way:
This way you don’t need to set anything at all when pasting in insert mode, and there is no need for alternative key combinations.
Supplement: I forgot to mention the side effects of this method. It will cause the options such as 'autoindent' and 'smartindent' in insert mode to be reset, so it is equivalent to canceling automatic indentation, so please use it selectively.
Use vi to paste the code and it’s OK
You can also do this
“+p
to paste;For convenience, I made a mapping
nnoremap <leader>p "+p
;Type
:reg
to see what's held in the register;Select some characters first, and then
”+y
you can copy the selected part to the system clipboard;Reference Accessing the system clipboard How to use vim registers?