Why is VIM's copy and paste broken and how to get it right?

vim

Solution

Turn on paste mode with `:set paste` to stop vim applying any indentation to the pasted text.

Problem

One thing I haven't figured out is how to get vim's copy and paste to work correctly. Can someone explain why it doesn't out of the box and how to get it to work that preserves the spacing etc? e.g. if I copy and paste a block of code from a browser, it should paste into vim with the spacing in tact.

Original source

Related problems