I'm experiencing frustrating behaviour with automatic Python indentation when ending a highly indented block. I've used pilcrows to indicate where I want newlines in the following example:
def f():
if True:
if True:
if True:
print ""
¶
¶
¶
def g():
print ""
After finishing typing the first function, every subsequent line is automatically indented by 16 spaces, which all need to be deleted. I understand that the first time I hit return, indenting to that level makes sense. But I am surprised that when hitting return on an unindented line it would also be assumed that I wanted the maximum valid indentation.
This behaviour seems to occur in 24.4.1 with both the new python.el
(Gallina) and python-mode.el
. (It also appeared to happen when I tried to use the old python.el
by Dave Love, but I could not work out how to verify which python.el
had actually loaded). I note that with the new python.el
I can use C-j
to return without indenting, but that doesn't help much with a situation such as the following:
def f():
if True:
if True:
if True:
print ""
¶
print ""
I don't want to disable automatic indentation, but is there a way to make it less aggressive and accept valid lower levels of indentation somehow?