rturrado
rturrado

Reputation: 8074

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, I used: set cino=i0,+2

Upvotes: 10

Views: 4067

Answers (2)

Andy
Andy

Reputation: 4866

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.

Upvotes: 3

Conspicuous Compiler
Conspicuous Compiler

Reputation: 6469

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;

Upvotes: 2

Related Questions