When Vim pastes code, hierarchical indentation is displayed. How to solve it?
滿天的星座
滿天的星座 2017-05-16 16:40:14
0
4
636

滿天的星座
滿天的星座

reply all(4)
淡淡烟草味

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:

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.

伊谢尔伦

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?

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!