Red Hat Bugzilla – Bug 161177
Automatic indentation doesn't work at all in vim
Last modified: 2007-11-30 17:11:08 EST
From Bugzilla Helper:
User-Agent: Mozilla/5.0 (Windows; U; Win98; en-US; rv:1.7.8) Gecko/20050511 Firefox/1.0.4
Description of problem:
No matter what I do, I can't get the automatic indentation to work in VIM. I've tried with both Python and C source files, and when I start a new block it does not indent, nor does it "dedent" when I close a block in C. Whatever indentation level it is at, it stays there for each new line until I change it.
I tried first with a stock install, then created a .vimrc containing the following:
Neither way works at all. This works fine on my SuSE 6.3 system.
Version-Release number of selected component (if applicable):
Steps to Reproduce:
Start VIM with a source file that should be indented, like test.c. Type in a properly-formatted function definition (for example) and note that the automatic indent doesn't happen when you start the block (with the open-curly).
Actual Results: It didn't indent.
Expected Results: It should have indented one tab-stop (four spaces with the vimrc described above).
Never mind. I just discovered the difference between vim-enhanced and
vim-minimal, namely that typing "vi" isn't the same as typing "vim" at the prompt.
This REALLY ought to be in the FAQ, as I looked there first.
Closing as NOTABUG based on last comment.
BTW: You might want to use smartindent or cindent, whichever better matches
your programming style. From the vim manual:
There are in fact four methods available for indentation:
'autoindent' uses the indent from the previous line.
'smartindent' is like 'autoindent' but also recognizes some C syntax to
increase/reduce the indent where appropriate.
'cindent' Works more cleverly than the other two and is configurable to
different indenting styles.
'indentexpr' The most flexible of all: Evaluates an expression to compute
the indent of a line. When non-empty this method overrides
the other ones. See |indent-expression|.