Vim: Pasting from clipboard and automatically toggling :set paste

Posted by Jonatan Littke on Stack Overflow See other posts from Stack Overflow or by Jonatan Littke
Published on 2010-03-31T18:41:22Z Indexed on 2010/03/31 18:43 UTC
Read the original article Hit count: 302

Filed under:

Hey.

When I paste things from the clipboard, they're normally (always) multilined, and in those cases (and those cases only), I'd like :set paste to be triggered, since otherwise the tabbing will increase with each line (you've all seen it!).

Though the problem with :set paste is that it doesn't behave well with set smartindent, causing the cursor to jump to the beginning of a new line instead of at the correct indent. So I'd like to enable it for this instance only.

I'm using Mac, sshing to a Debian machine with vim, and thus pasting in Insert mode using cmd-v.

Cheers.

© Stack Overflow or respective owner

Related posts about vim