Emacs python translate the start or end of a for loop
In emacs, when editing in python, how do I move the cursor from the beginning of the for loop to the end?
In other languages that use curly braces, by typing in C-M-n
or C-M-p
from the position of the curled bracket, the cursor moves to the end or beginning of the loop. Is there a similar keyboard shortcut for python code?
Example: Jumping from the beginning of a loop foo to the end or loops of strokes or xyz:
for foo in foolist:
for bar in barlist:
if foo > 100:
print "foo large"
else:
if bar > 100:
print "bar large"
else:
print "bar small"
for xyz in xyzlist:
print "xyz" . xyz
Editorial staff:
I tried with this code below and started to finish, but end to beginning doesn't work, it jumps from end else
to end of the corresponding if
:
(define-key python-mode-map "\C-\M-n" 'python-nav-end-of-block)
(define-key python-mode-map "\C-\M-p" 'python-nav-beginning-of-block)
source to share