There are cases where my indentation style does not follow what Emacs thinks it should be. (I believe that coding standards should be guidelines, not strict rules, and that deviations should be acceptable if there's good justification for them.)

For example, I might want to format code in C like:

if (   test_some_condition()
    && test_another_condition()
    && test_yet_another_condition())
    // ...

So I type:

if (   test_some_condition()
    && test_another_condition

but when I press (, Emacs will aggressively reindent my current line to:

if (   test_some_condition()
       && test_another_condition(

Is there any way disable that? That is:

  • I do want new lines to be automatically indented based on the previous line.
  • Once I start typing, I've already indented the current line the way I want it, and I don't want it to be reformatted when I press (, ), RET, etc.

2 Answers 2


You can try

(add-hook 'c-mode-hook
          (lambda () (setq-local electric-indent-inhibit t)))

tho I'm not sure if the C mode obeys this variable. If it doesn't work, I suggest M-x report-emacs-bug.


What I do is press C-q before typing any electric character, such as ();{} which serves to remove their electric behavior temporarily.

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.