tags:

views:

272

answers:

4

I'm using vim 7.0.

I want the following code be indented in the following way (initialization list in the same indentation as constructor):

  A::A() :
  a1(10),
  a2(10),
  a3(10)
  {
  }

According to vim help this can be done by setting:

set cino+=i0

But this setting yields (only a1 is indented correctly):

A::A() :
a1(10),
    a2(10),
    a3(10)
{
}

Setting cino+=i1 indents correctly a1..a3 with 1 space indentation.

A: 

have you tried "set smartindent"? i think it does what you want.

Dyno Fu
Do you have a clue what I set it to?
dimba
you mean you want cindent, and set options to get the effect of the first code block? i just mean with all the default setting, (without the "set cino+=i0"), "set smartindent" does exactly, the same indent as the first code block.
Dyno Fu
+1  A: 

Try this. Basically I had a quick play with the cino options. Not sure if it will affect any of your other formatting preferences but looks ok to me.

:set cino=i0,n0,+0
Richard
+1  A: 

Looks like this is a genuine bug in vim since cino=i1 does the right thing, but cino=i0 doesn't. :help bugs for information on what to do from here.

Geoff Reedy
+1  A: 

According to documentation and a little experiment, the following could help:

:set cino=i-s

Seems to be indenting init list exactly as you wanted.

Dmitry