When I run the command forward-sexp
at the beginning of the line in Python mode, my cursor jumps to the end of the line. I assume that the line is a statement, and is therefore considered to be a sexp. Can I modify this behavior so that forward-sexp only jumps to the end of the symbol?
Steps to Reproduce:
Paste the following lines into a buffer in Python mode
def dummy():
my_count_variable = 0
(a, b, c) = (1, 2, 3)
return my_count_variable
Case 1:
- Move the cursor to the
m
at the beginning ofmy_count_variable
- Call
forward-sexp
(C-M-f
) - Notice that the cursor has jumped to the end of the line
- (I would prefer to jump to the end of the symbol here)
Case 2:
- Place the cursor at the beginning of the second line, just under the
d
indef
- Call
forward-sexp
(C-M-f
) - Notice that the cursor has moved to the end of
my_count_variable
- (This seems inconsistent with Case 1)
Case 3:
- Place the cursor at the first
(
on the third line - Call
forward-sexp
(C-M-f
) - Notice that the cursor jumps to the end of the first tuple instead of the end of the statement.
- (Again, why not jump to the end of the expression?)
Is there a way to modify the behavior of forward-sexp
so that it does not treat a python "statement" as a balanced expression? There seems to be some inconsistency which causes the command to work how I want, but only sometimes (i.e. cases 2 and 3).
Note: I am using the built-in python-mode from python.el