开发者

Looking for the correct cinoptions for this piece of code

What cinoptions can I set for getting the block below indented as shown?

f(int *p) 
: a(p)
, b(0)
{
  std::cerr << blah
    << foo << std::endl;
}

The closest I've got was to:

f(int* p) 
  : a(p)
  , b(0)
  {
    std::cerr << blah
      << foo << std::endl;
  }

That's almost what I want, only that everything after : is indented :)

For that开发者_如何学Go, I used: set cino=i0,+2


How about i0,+2,t0? (tN is for "a function return type declaration").

That worked for me, but, the vims I tried (7.0 and 7.3) did two different things, neither the same as yours, with i0,+2.


It looks like you only need one additional option. I got the results you expected by adding p0 to the cinoptions:

set cino=i0,+2,p0

This adjusts the K&R style indentation. From the docs:

pN    Parameter declarations for K&R-style function declarations will
      be indented N characters from the margin.  (default
      'shiftwidth').

    cino=               cino=p0          cino=p2s
      func(a, b)          func(a, b)       func(a, b)
          int a;          int a;                   int a;
          char b;         char b;                  char b;
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜