cgmocq
Last Updated: February 25, 2016
·
515
· marinftw

Vim paste mode or how to avoid paste autoformat

Every time you paste code on your buffer from your clipboard (if you use vim on a terminal) it will auto indent or auto comment in a top to bottom way your lines of pasted code.
If you want to avoid this behavior you simply have to switch to paste mod via:

:set paste

of course it's easier to map it on the keyboard like this:

nnoremap <F2> :set invpaste paste?<CR>
set pastetoggle=<F2>

Now F2 will set your insert mode on.

Hope it helps!