Interactive Python programming in ... vi [was: Tab wars revisited]

Lonnie Princehouse finite.automaton at gmail.com
Mon Jul 19 13:34:30 EDT 2004


> OK, so this could be one way of emulating the REPL (but I hope that
> there might be a more convenient way).

Yeah, a complete interpreter is lurking in the background, but it _is_
difficult to interact with.  I use it mostly as a way to script VIM,
but not on the fly; I just keep a bunch of handy functions in a module
(called "vimfu") which gets imported by .vimrc.  The vim module
provides a nice pythonic way to manipulate buffers, selected regions,
etc.

You can do all of this stuff with LISP in Emacs, but Python works
pretty well for scripting VIM.

> > Reading the help file on :python is highly recommended!
> 
> So, am I right in thinking that it's just a single chunk of text, with
> some colouring ... which one is supposed to read by scrolling up and
> down, or is there more to it (it _looks_ as if there is ...) ?

It is indeed arcane.  Ctrl-] will follow the colored links.

> 
> I guess I really should find the time to go through this with an
> interested vim user.
> 
> > *only works from inside the embedded interpreter

> Hmm, that makes me slightly nervous ... do you get to see some
> vi-specefic inerpreter state ... with which you might clash ?

I doubt that is an issue.  The vim module interacts directly with a
VIM session, which is why I don't think it can be run outside of VIM. 
You could put it in your PYTHONPATH and give it a shot, though-- I
haven't actually tried =)



More information about the Python-list mailing list