Editor with Python backend

Johann Hibschman johann at physics.berkeley.edu
Tue Mar 21 20:03:14 EST 2000


Charles Boncelet writes:

> I use vim and have read these man pages, but I still haven't
> figured out why? What would I use python for from within vim?
> How do you use python within vim (or any other editor)?

Well, I've just started work on such an embedded-python editor
project, so I'd better have a reason.  ;-) Actually, I'm mostly trying
to learn how to work pygtk, but it's still fun.

Why is it good?  It lets me write programs (in python) to do things
like word-wrapping, justification, and so on.  It lets me modify
documents, using my knowledge of python.

Here's an example.  Say I have a file with ^M's and spurious spaces at
the end of the lines.  I can type in the interpreter window:

for line in buffer["filename"].modifiable_line_iter():
  line.set(string.rstrip(line.get())+"\n")

and see the results in the editor window.  That's a pretty trivial
example, but the idea is that you can apply "batch" transformations to
a document by just typing a few lines of python.

Mostly, it's to let me add features to the editor in python, rather
than elisp.  (If only that common-lisp emacs project would get
going...)

-- 
Johann Hibschman                           johann at physics.berkeley.edu



More information about the Python-list mailing list