Vim Screencast: % Operator
Here's another in my series of vim screencasts. This one talks about the various uses of the % operator. You can find the video at http://showmedo.com/videotutorials/video?name%3D3160020 (likely dead)
In non-editing mode, the % operator swaps between (), [] or {} style braces. This is super helpful for PHP style syntax that wraps large portions of code in these. The real power of the % operator comes in Ex mode, however.
Ex mode is the mode that is triggered by the colon ( : ). It prefaces such commands as :w[rite] or :q[uit]. In this mode, the % sign represents your current working file. You can use it to great effect with the ! operator which escapes to the shell temporarily. This allows commands such as::
:!ls -l %
which shows you the permissions of your current file. You can use it to run your current file through a python interpreter with::
:!python %
Another use of this command is to add command line output to the current buffer with commands akin to::
:!ls -l >> %
which uses bash redirection to add the text to the bottom of the file.