I have the following:

int main()

  int a = 1;
      int b = 2;
  return 0;

I am expecting some lint to align the indentation. My file is open with (C/*l AC Abbrev).

I try C-c . which asks me:

Which C/*l indentation style?

I select k&r and hit enter. Then nothing happens. I try the others, awk, or python, and same thing, no linting occurs to tab the int b back over. When I try again with C-c . it asks again but never lints my code.

What should I do to get formatting in C in emacs?

1 Answer 1


C-c . just sets the formatting style to use when indenting the code, it doesn't actually change the indentation of anything the buffer. You can change the indentation of a region with the indent-region command, bound by default to C-M-\. c-mode also has the c-indent-exp command that indents an expression; this is handy for multi-line expressions near the cursor. TAB is bound to c-indent-line-or-region, which will reindent the current line should it be out of place. It also reindents regions like C-M-\, which is a little unusual. Most modes leave them separate.

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.