vim - indentation of C++ constructor initialization list problem

余生长醉 提交于 2019-12-13 12:27:52

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!