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?

2
  • 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. Commented Jan 10, 2019 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) Commented Jan 10, 2019 at 12:51

1 Answer 1

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 and acknowledge you have read our privacy policy.

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