问题
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.
回答1:
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.
回答2:
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
回答3:
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.
回答4:
have you tried "set smartindent"? i think it does what you want.
来源:https://stackoverflow.com/questions/1973471/vim-indentation-of-c-constructor-initialization-list-problem