Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Smart indenting in vim (normally great) is a disaster when pasting in a chunk of code

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?

like image 674
dreeves Avatar asked Jan 22 '09 19:01

dreeves


1 Answers

: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.

like image 178
Craig H Avatar answered Oct 22 '22 01:10

Craig H