That functionality is provided by the matchit plugin that is bundled with Vim. The distributed C filetype plugin includes the configuration
b:match_words that defines those jumps for the matchit plugin.
Unfortunately, the distributed python filetype does not include a similar change. You can however configure
b:match_words for that case. Simply put the definition of the
b:match_words variable into
~/.vim/after/ftplugin/python.vim (create non-existing direcotories).
Even better would be to create a PR with a working definition for the
b:match_words variable at the upstream python filetype repository so that it can be distributed with one of the next runtime files updates.
For the configuration of the
b:match_words variable, see the help page at :h b:match_words. (You might need to do
:packadd matchit or the help file won't be found.)
So it looks like this might be more complex for python, because python uses no explicit end delimiter but rather the number of spaces. I did not think of it, because I usually do not use python. However, it should still be possible to match those parts. I tried with this simple(?) regex for matching
let b:match_words = &matchpairs . ',^\(\s*\)\<if\>:^\1\<elif\>:^\1\zs\%(elif\)\@!.'
(That works, because it matches the number of spaces in front of the if statement and uses that to match either to the next
elif or the end of the if block. A similar think should work for
for and similar blocks). However one caveat: doesn't work if the if block itsself is the last part of an containing block, so this it does not catch currently:
for line in input.readlines():
Also there seems to be a bug in the matchit plugin, because adding
\zs to the
elif pattern to make the cursor stop at the beginning of the elif (instead of at the beginning of the line), breaks it. Not sure why.
However, the basic principle should be clear with the example.