vim does incorrect autoindentation in the following example:

Bug #43636 reported by Allison Karlitskaya
6
Affects Status Importance Assigned to Milestone
vim (Ubuntu)
Fix Released
Low
Unassigned

Bug Description

Binary package hint: vim

write this program (formatted as follows) with autoindentation on in vim:

#include <stdio.h>

int
main (void)
{
  printf ("Hello world\n");

  return 0;
}

vim gets the indenting correct.

now go up to the line with "int" on its own. enter insert mode at the start of that line. press enter to insert an additional blank line between #include and int. 'int' now incorrectly indents to the right.

Revision history for this message
Dennis Kaarsemaker (dennis) wrote : Re: [Bug 43636] vim does incorrect autoindentation in the following example:

Can't reproduce here...

Revision history for this message
Gary Coady (garycoady) wrote :

I can see this:
vim file.c
(then follow the steps in the bug)

The indentation mode is cindent, rather than autoindent. It appears to be due to the code which indents after a #ifdef-style line.

One could modify the value of 'cinkeys' as a workaround (see indent.txt in the vim help), but this would also stop correct indentation after #ifdefs/#define/etc.

Changed in vim:
status: Unconfirmed → Confirmed
Revision history for this message
Gary Coady (garycoady) wrote :

This will be fixed when vim is updated to version 7.0 (couldn't reproduce in that version).

Revision history for this message
Zygmunt Krynicki (zyga) wrote :

This is the proper behaviour. Try help cinopts to check out why.

Revision history for this message
Allison Karlitskaya (desrt) wrote :

True story. 'set cino=t0' fixes this.

Perhaps this should be added to the default config?

Revision history for this message
Allison Karlitskaya (desrt) wrote :

(noting of course that this is the new upstream default behaviour...)

Micah Cowan (micahcowan)
Changed in vim:
status: Confirmed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.