In org-mode, for the given block:
#+BEGIN_SRC python
def hello():
print('Hello world!')
#+END_SRC
I enter the source code editor with C-c '
and the syntax highlighting and indentation and everything else works correctly.
However, after I exit the mode with C-c '
, 2 spaces of indentation are added so that the source code now appears like this:
#+BEGIN_SRC python
def hello():
print('Hello world!')
#+END_SRC
How do I fix it so that the indentation is preserved after editing the code block?
You can preserve the indentation after editing a code block in org-mode by setting the following variables (thanks to Angelo Basile's article, "Org-mode Babel is cool" for the tip):