[Tutor] Re: Using Python with VI

Barry Smithers barrys at datatree.co.uk
Wed Feb 4 04:16:39 EST 2004

Thanks for that Abel, exactly what I needed.



----- Original Message ----- 
From: "Abel Daniel" <abli at freemail.hu>
To: "Barry Smithers" <barrys at datatree.co.uk>
Cc: <tutor at python.org>
Sent: Tuesday, February 03, 2004 8:52 PM
Subject: Re: Using Python with VI

> "Barry Smithers" writes:
> > I'm having difficulty with a program call from inside of VI.  What I
> > basically need to do is get the line numbers input in the ex command.
> > maybe even get the text on those lines to go into a list.  For example
> > ex command ":20,21!xxx.py" would run xxx.py as a whole, but I need the
> > currently on lines 20 and 21 for modification.
> This ex command expects the program you run (xxx.py) to be a filter: it
> read on stdin and write to stdout. Something like this:
> ---
> import sys
> l=sys.stdin.readlines() # this l will be the list you need
> print "l:", l # print writes to stdout by default. Or you can use
>               # sys.stdout.write()
>               # (and .flush(), and .close(), just to be safe)
> ---
> I don't know how you could pass the _line_numbers_ (instead of the
> of the lines).
> -- 
> Abel Daniel

More information about the Tutor mailing list