(Emacs) Brackets aren't indenting correctly

Viewed 53

In emacs, when I type this:

if(true)
{

I get this:

if(true)
  {

So then I have to press the left arrow to move back one space, then delete the two extra spaces to get the expected result. Any ideas on how to fix this?

1 Answers

Check what the RET key is bound to in the current mode. Bind it to something else, such as newline.

Or just turn off electric-indent-mode, by putting this in your init file:

(electric-indent-mode -1)

That turns off having RET (the Enter key) automatically indent, in most programming modes.

Related