sponsor Vim development Vim logo Vim Book Ad

python.vim : python compiler script

 script karma  Rating 39/19, Downloaded by 2967  Comments, bugs, improvements  Vim wiki

created by
Christoph Herzog
script type
a very basic python compiler script. The last line of errorformat
is meant to suppress all  further error messages after the traceback has been dealt with so that it will be possible to use :clast to go to the last error location which in most cases in Python is the one that has caused the error to happen.
Please note that if python is not in the path you have to edit the line
setlocal makeprg=python
so that it contains the path of the python interpreter (e.g. c:\python22\python).
Also, if you want always to make the current file you may wish to add  a
\ %
to the same line, so that:
setlocal makeprg=python
should then look like:
setlocal makeprg=python\ %
(Thanks to Guy Oliver for this tip).

If you want to syntaxcheck the current python file without executing it, you could use the following function (from python_box.vim):

function! CheckPythonSyntax()
  let curfile = bufname("%")
  exec ":make " . "-c " . "\"import py_compile; py_compile.compile(r'" . bufname("%") . "')\""
install details
just add to the compiler plugin directory

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.vim 0.1 2002-11-10 6.0 Christoph Herzog Initial upload
ip used for rating:

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.