emacselisp

Emacs Org Mode: Why does RET add an indentation and how can I stop it?


If I have this line

- line 1<cursor>

I see that typing RET will run command org-return and the cursor moves here

- line 1
  <cursor>

instead of here where i'd like it to be

- line 1
<cursor> (beginning of the line)

I see in my scratch buffer, typing RET runs newline so I try running that command but that also results in an indentation. How can I have the desired result where RET will create a newline and place the cursor at the beginning of the newline?


Solution

  • I see in my scratch buffer, typing RET runs newline so I try running that command but that also results in an indentation.

    That firmly suggests that it's on account of electric-indent-mode.

    It's not unreasonable to leave that enabled for org-mode though, as list items can span multiple lines:

    Items belonging to the same list must have the same indentation on the first line. In particular, if an ordered list reaches number ‘10.’, then the 2-digit numbers must be written left-aligned with the other numbers in the list. An item ends before the next line that is less or equally indented than its bullet/number.

    And if you want to start a new list item, you can type M-RET instead of RET (or indeed after it, if you forgot).

    You can always use M-\ to delete the current indentation.

    Or, experimentally, RET x 3 drops the indentation back again (albeit that's probably one too many to be the most convenient option).