2

When I have a long constructor that forces me to put initialization list items on separate lines, my indentations look like this after gg=G.

Really_Long_Class_Name::Really_Long_Class_Name(int _arg1, int _arg2) :
  arg1(_arg1),
  arg2(_arg2) {
    do_stuff();
  }

I want it to be indented like this:

Really_Long_Class_Name::Really_Long_Class_Name(int _arg1, int _arg2) :
    arg1(_arg1),
    arg2(_arg2) {
  do_stuff();
}

After looking at a similar question, I got closer by playing around with cinoptions. By using :set cino+=i4,e-4,0}-4 I got it to look the way I want, but then my alignment is screwed up if all the initialization list items are on the same line, like so:

Other_Class::Other_Class(int _arg1, int _arg2) : arg1(_arg1), arg2(_arg2) {
do_stuff();
}

How can I fix indentation for this one case without throwing off indentation for other cases?

1
  • c++ syntax is too complicated for vim to recognize, you should look for some plugin to help you indent your code, like the clang_complete and Youcomplete me.
    – walkerlala
    May 9, 2016 at 11:27

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Browse other questions tagged or ask your own question.