2

Emacs indents functions in structs in the following way:

struct A {
    int a() {
        return 1;
    }

    int b()               
        {
            return 2;
        }
}

int c() {
    return 3;
}

int d()
{
    return 4;
}

I want b to be indented just like d. How can I fix this?

  • 1
    What you can do is changing the c-default-style variable to change indent behaviour. the variable c-style-alist shows the available styles. You can check the different styles on Wikipedia. – AltruisticDelay Jan 10 at 7:02
  • I gotta add, as a C++ veteran (and still going), that this is pretty standard indentation (add one level to inner struct methods) – Felipe Lema Jan 10 at 12:51
0

Not adding a level after opening curly braces is the default behaviour in Emacs and it's addressed in the EmacsWiki on how to avoid it:

(setq c-default-style "linux"
      c-basic-offset 4)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.