I am an average vim user and with an avarage .vimrc containing:
set autoindent
It's not that bad in general, but when it comes to copying the content from outside, I get the indentation of this piece terribly messed up. Even worse, if the text contains the comments like "//", they are propagated to the next lines of the copied content even if they originally were not commented. gg=G doesn't help.
Is there any way to set the autoindent to be disabled on the action of copying something from outside?
This is described on the Vim wiki. Try adding this to your .vimrc
:
set pastetoggle=<F2>
You can set any key - <F2>
is just an example. Then just press your key to allow pasting, do your copy into Vim, then press the key again to return to normal autoindent behaviour.