sponsor Vim development Vim logo Vim Book Ad

python_match.vim : Extend the % motion and define g%, [%, and ]% motions for Python files

 script karma  Rating 124/50, Downloaded by 6332  Comments, bugs, improvements  Vim wiki

created by
Benji Fisher
 
script type
ftplugin
 
description
This script redefines the % motion so that (in addition to its usual behavior)
it cycles through if/elif/else, try/except/catch, for/continue/break, and
while/continue/break structures.  The script also
defines g% to cycle in the opposite direction.  Two other motions, [% and ]%,
go to the start and end of the current block, respectively.

All of these motions should work in Normal, Visual, and Operator-pending
modes.  For example, d]% should delete (characterwise) until the end of the
current block; v]%d should do the same, going through Visual mode so that
you can see what is being deleted; and V]%d makes it linewise.
 
install details
Copy the file to your ftplugin/ directory.  If, for some reason, you want to
change the name of the file, copy it to ftplugin/python/ or :source it from
ftplugin/python.vim .
 

rate this script Life Changing Helpful Unfulfilling 
script versions (upload new version)

Click on the package to download.

package script version date Vim version user release notes
python_match.vim 0.5 2003-10-02 6.0 Benji Fisher I added support for for and while loops:  % and g% go between the start of the block and either break or continue lines.

I reorganized the code and made several minor improvements.  For example, [% and ]% now accept a count,  `` goes back to where you started, and g% does nothing (insteadof acting like the default %) if the cursor starts on a line that does not begin with a recognized key word.
python_match.vim 0.4 2002-08-16 6.0 Benji Fisher Initial upload
ip used for rating: 3.143.17.128

If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to the maillist. Help Bram help Uganda.
   
Vim at Github