I do a lot of python coding and am trying to determine if electric indent can be customized to help me with the following scenario:
Let's say my cursor (point) is at the end of the following excerpt, at the 'X':
if (some_condition):
do_something()
and_do_something_else()X
return
If I hit RET, the cursor is moved to the next line immediately below the 'a'. Great. BUT... if all I want to do is insert a blank line, I will quickly move point somewhere else, and then some unwanted whitespace is left in the empty line:
if (some_condition):
do_something()
and_do_something_else()X
.... # <-- unwanted whitespace left here
return
Binding RET to electric-indent-just-newline
does not give me what I want, because that causes the cursor, in this scenario, to go to column 0.
I guess what I'm looking for is a clean way to:
- Automatically move the cursor to the same level of indentation as the previous line if I hit RET, BUT
- If the subsequent line just needs to be a newline / blank line, don't poop it up with whitespace.
Or do I need to resort to calling the function that deletes trailing whitespace?
Please let me know if I need to clarify the problem I'm trying to solve.
C-o
to add a newline after point and then move it somewhere else.