Reputation: 26932
I guess other editors are smart enough to turn that stuff off for pasting but when using vim in a terminal it can't distinguish between pasting and actual typing.
What kinds of solutions or workarounds do you have for this?
Added: there's also a setting that makes comments automatically continue on the next line. The indenting at least doesn't change the semantics of the code but the auto comment continuation really screws things up. Come to think of it, I should just turn that off altogether -- anyone know what that option is called?
Upvotes: 13
Views: 5012
Reputation: 6060
Another way to do this, assuming you have your system clipboard set up properly is to do
"*p
This will paste from the system clipboard.
Check your vim --version
. On OS X you'll need +clipboard
and on Linux +xterm_clipboard
, I believe.
If you're on OS X, you can always brew install macvim
and use mvim -v
instead of the bundled Vim (it was not compiled with +clipboard
).
Upvotes: 1
Reputation: 3844
add this to your .vimrc and use it with the F2 key to toggle paste status before and after you add in chunks of code:
set pastetoggle=<F2>
Upvotes: 7
Reputation: 7989
:set paste is the way to go, but if you forget, as I often do, then if you are using a language with {} as the open/close of blocks, then doing a =% on the first { or last } will reapply the indenting.
Upvotes: 21