With Vim 8+ on Linux or Mac, you can now simply use the OS' native paste (ctrl+shift+V
on Linux, cmd+V
on Mac). Do not press i
for Insert Mode.
It will paste the contents of your OS clipboard, preserving the spaces and tabs without adding autoindenting. It's equivalent to the old :set paste
, i
, ctrl+shift+V
, esc
, :set nopaste
method.
You don't even need the +clipboard
or +xterm_clipboard
vim features installed anymore. This feature is called "bracketed paste". For more details, see Turning off auto indent when pasting text into vim