When Vim is pasted, the formatting problem is caused by indentation.
---------------------------------------------------------------
Original: http://www.cnblogs.com/softwaretesting/archive/2011/09/20/2182177.html
If you set the auto indent set autoindent in. VIMRC, when you paste the code in insert mode, VIM automatically indents the code, resulting in a confusing format. The solution is as follows
Setting the set paste option in. VIMRC does not cause indentation when pasting the code, but changes the option back to set Nopaste if indentation is required. It's a hassle to change, so you can set a switch.
Set Pastetoggle <F9>
So, you can turn the paste option on and off by pressing the F9 key, press F9 before pasting, and then press F9 when you need to indent.
The default tab in Vim contains 8 spaces, if you prefer the 4-space mode, add the following options
Set Tabstop=8
Solve the problem of confusing format when Vim is pasted