Recently I've been using electric indent mode to handle automatic indentation. It's very useful when writing code, as it indents blocks automatically when the enter key is pressed. But some of that behaviour isn't desirable when using other modes, such as org mode.

One thing I like about org-mode is the keyboard shortcuts for inserting new headlines and todo items. For example, ALT+ENTER will create a new headline beneath the current line at the correct depth.

Unfortunately, when using electric indent the headlines are indented:

Emacs org-mode with electric indentation

Thankfully the solution is relatively simple. Placing either one of the following pieces of code in your Emacs intialization file will disable electric indentation when working with org files.

;; Method one.
(add-hook 'electric-indent-functions
	  (lambda (x) (when (eq 'org-mode major-mode) 'no-indent)))

;; Method two.
(add-hook 'org-mode-hook
	  (lambda () (electric-indent-local-mode -1)))

So now you'll get the expected behaviour:

Emacs org-mode with electric indentation