vim auto indenting even after setting noai option

This has nothing to do with the noai option. What you are experiencing, is a little trouble copy-pasting a load of text with existing indents to vim.

What I usually do (I have this 'problem' a lot), is bind F4 to invpaste and then, before I paste stuff into vim, hit that key. It makes the problem go away.

nnoremap <F4> :set invpaste paste?<CR>

Read more about this using

:help paste 

inside vim


:set paste prevents the problem

:set nopaste to undo the above

:set pastetoggle=<F2> sets paste toggle key to F2