Interactive Python programming in ... vi [was: Tab wars revisited]
G. S. Hayes
sjdevnull at yahoo.com
Fri Jul 16 22:05:29 CEST 2004
Martin Christensen <knightsofspamalot-factotum at gvdnet.dk> wrote in message news:<87d62xoun1.fsf at gvdnet.dk>...
> Mark> It sends the entire selected block to a new interpreter, yes.
> Mark> Not each line to a different interpreter, if that's what you're
> Mark> trying to say.
> I think what he was trying to say is this: for each time you send a
> code snippet to the interpreter, a new interpreter is started, and
> afterwards you won't have the same interpreter and its state to play
> With Emacs' Python mode, you can run a so-called inferior Python
> process, which is just to say that you have an interpreter running in
> Emacs. You can then keep sending code to this same interpreter.
> I should be greatly surprised if it weren't possible to do something
> similar in at least Vim.
The vimsh package allows you to run a shell under Vim; among other
things, you can run python under this shell. I do this all the time,
with macros to run selected line(s) from my python code in the Python
window, maintaining state in between sending lines through Python--so
running "i=100", then going back to editing and later running "i=i+1",
"print i" will print 101.
This runs seperately from Vim's built-in Python interpreter, so you
don't have to worry about namespace collisions, etc (in fact, you can
easily have several vimsh python windows each running their own
interpreters, just like in emacs).
vimsh doesn't have smart terminal emulation (just dumb ptys), though,
so you can run line-oriented programs fine this way, but you can't run
e.g. curses or advanced termcap programs in any useful way. Not a big
deal for me.
More information about the Python-list