Thursday, January 29, 2009

Pasting code in VIM is broken, here's the fix


Copying and pasting code snippets from other applications or a browser is du jour these days. If you're a VIM user like me, you've definitely run into the problem of Vim mysteriously inserting a lot of extra white space into pasted code. This is Vim being smarter than it should be - it thinks that you are actually typing and not pasting, so it proceeds to re-indent already indented code. The fix is simple:
:set paste
Paste the code in Insert mode, and once done, type the following command:
:set nopaste

Q.E.D.

0 Comments:

Post a Comment

Links to this post:

Create a Link

<< Home