Vim scripting with python

sjdevnull at yahoo.com sjdevnull at yahoo.com
Tue Feb 13 05:43:43 EST 2007


J. Clifford Dyer wrote:
> Stuart D. Gathman wrote:
> > On Sat, 03 Feb 2007 05:02:54 -0800, Tool69 wrote:
> >
> >> Does anyone have any advice, and more genraly how to script Vim with
> >> Python ?
> >
> > :py import sys
> > :py print sys.version
> > :help :py
> >
> >> I know I can put some python functions inside my vimrc file like
> >> this :
> >>
> >> function! My_function()
> >> python << EOF
> >> import vim, string
> >> ...blablabla
> >> EOF
> >> endfunction
> >>
> >> but I would like to use external ".py" files.
> >
> > :py import myfile
> >
> > Use :py inside your vimrc - don't run python externally.
>
> Which versions of vim is this valid for?  I tried ":py print 'Hello'",
> and got "E319: Sorry, the command is not available in this version"

It's valid for vim 5.0 and later (all official vim releases since
March 1998).  You have to make sure python support is enabled at build
time with --enable-pythoninterp or other configure options that turn
it on (check for +python in the output of ":ver" to see if a
precompiled binary includes python support).




More information about the Python-list mailing list