Vim - indents of the C ++ constructor initialization list task

I am using vim 7.0.

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

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

According to vim, this can be done by setting:

 set cino+=i0 

But this parameter gives (only a1 correctly edited):

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

Setting cino + = i1 to correctly render a1..a3 with 1 space indent.

+4
source share
4 answers

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

 :set cino=is 

It seems that you want to cancel the initialization list exactly the way you wanted.

+3
source

Try it. Basically, I had a quick game with cino options. Not sure if this will affect any of your other formatting settings, but it looks good to me.

 :set cino=i0,n0,+0 
+1
source

This seems like a real bug in vim, since cino=i1 does the right thing, but cino=i0 does not. :help bugs for information on what to do next.

+1
source

Have you tried "set smartindent"? I think he does what you want.

0
source

All Articles