- You're correct that
autoindent should do what you want, but it might be overruled by the archaic
Be sure you're not in vi compatible mode. You want
set compatible? to return
nocompatible. This means that Vim will not be backwards compatible to the old vi program. In older Vim versions, it started up in
compatible mode by default and left it to the users' .vimrc files to include
Newer versions of Vim will automatically start up in
nocompatible mode, which is what you want.
- Many common file extensions will get the
filetype setting assigned. If
detection: ON and
indent:ON, then the filetype indentation might be setting the
indentexpr to a function which should be better than
smartindent, but maybe it's worse. What is your filetype?
indentexpr should be
I usually recommend not using
smartindent and instead use filetype indentation.
In summary, these two lines in a ~/.vimrc should help out:
filetype plugin indent on