Wednesday, June 16, 2010

How to disable autoindent in VIM

When copy/paste from one source to the other (e.g. sample code), vim auto-indent makes too much indentation, so you want to quickly turn it off. Here is a command:
:setl noai nocin nosi inde=
Here is a mapping (add to file ~/.vimrc):
" Disable autoindent in VIM
nnoremap <F8> :setl noai nocin nosi inde=<CR>
Alternatively, you can use:
" Turning off auto indent when pasting text into vim
set pastetoggle=<F8>
So now, before pasting something in, you press F8 to disable auto-indent.