For years I’ve been trying to figure out how to keep Vim from automatically indenting when I copy from one file to another.
Stackoverflow mentioned this page buy a developer named Marcin Kulik
Automatically set paste mode in Vim when pasting in insert mode
let &t_SI .= "\
let &t_EI .= "\
inoremap
function! XTermPasteBegin()
set pastetoggle=
set paste
return ""
endfunction
This code automatically turns off the Vim indent functionality when new text is pasted into a file. Just add it to your .vimrc file.
It’s the same as a set paste and set nopaste before and after pasting new text, but it happens automatically. I’ve tested it and it seems to be working PERFECT. I love it!