It always annoys me when my text editor types things for me. Vim does this
when it thinks I want to indent code with a certain amount of whitespace,
which is usually the case, but I want to type the whitespace myself so that
I know what's going on. Even worse is when it realises I'm typing a comment
and starts inserting # or * characters for me.
The obvious settings to put in your .vimrc file to turn automatic indentation off would be something like this:
" Turn off simple indentation (if the current line is indented, " autoindent will indent the next line by the same amount). set noautoindent " Turn off C-style indentation (which adds indentation after lines " which end with a { character, for example). set nocindent " Turn off the two 'formatoptions' ('fo' for short) which " automatically insert comment characters for the current filetype " when Vim thinks you want to add a line to a comment. set fo-=r fo-=o
This isn't enough though, because these values can get overridden by
filetype plugins, which set options they think are appropriate for particular
types of file. So files which Vim thinks are C, C++ or Java programs get
the cindent option turned on when you start editing them.
According to the documentation, you can avoid this as follows:
" Should turn off the automatic indentation options set " by filetype-specific 'indent' plugins, but doesn't. filetype indent off
This prevents Vim from loading files like indent/c.vim, which
set indentation options for specific languages, but it unfortunately it
doesn't have the desired affect (at least for Vim 6.1 on Debian). The
indentation script for C has setlocal cindent in it, as you'd expect,
but the generic filetype plugin ftplugin/c.vim also sets that,
which I think is a mistake. The generic script also sets the options which
continue comments across lines, so that solution probably wouldn't be
adaquate anyway.
The solution I'm using for now, which does seem to work, is to set certain
options after the filetype-specific commands have been run, and doing so
for every file type. That can be done with an autocommand for the
FileType event:
" This works, and overrides the options for any filetype. autocmd FileType * set fo-=r fo-=o nocindent noautoindent
By the way: my distaste for automatic indentation is one of the main reasons I don't use Emacs, because both Emacsen make it almost impossible to turn this stuff off.