Extra spacing in Vim when copying and pasting from Chrome
vim
Solution
When you paste using any of your terminal/OS's default method (menu, contextual menu, shortcut, mouse…) the text is not pasted: it is inserted as if you typed it. Because you have enabled autoindenting, Vim indents every line and you end up with that stairway (to hell) effect.
You have two options…
`paste/nopaste` and/or `pastetoggle`:
You can do `:set paste` to disable autoindenting and formatting before you paste and do `:set nopaste` afterward.
If you decide to take that path, I suggest you read `:h pastetoggle` to make the whole process a little less taxing.
Vim's own commands and clipboard integration:
If your Vim build comes with clipboard support, you can use `"+p` or `"*p` to paste from other programs without side effects.
The default Vim that comes with most OSes is a "small" build that may lack a number of useful features. If you intend to use Vim as your primary editor for programming it is advised to install a beefier build that comes with clipboard support. On Debian-based systems, the best choice is usually "vim-gtk" or "vim-gnome". On Arch, I think you have to install the "gvim" package.
Problem
Whenever I copy text that has been indented into Vim from Chrome, I get a cascading indent instead of a consistent one, so: ``` def fn(x): """Takes x as an input and returns y if x: return y ``` becomes: ``` def fn(x): """Takes x as an input and returns y if x: return y ``` How do I prevent this (preferred), or how do I quickly fix the spacing using other vim commands (acceptable)? Extra Info - vim 7.4, chromium 34 on Arch Linux - Copy method: highlight (mouse or otherwise) in Chromium, `CTRL-C`, switch to vim and insert mode, `SHIFT-CTRL-V`.