淡淡烟草味2017-05-16 16:42:14
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
滿天的星座2017-05-16 16:42:14
I always use another better way:
augroup PASTETOGGLE
autocmd! InsertEnter * setlocal paste
autocmd! InsertLeave * setlocal nopaste
augroup END
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.
阿神2017-05-16 16:42:14
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?