sending vim text through Python filter

B

BartlebyScrivener

Hello,

I'm sure this is my fault or some Windows snafu. But using gvim 7.0 on
Windows XP, I can't seem to get gvim to successfully filter text
through a Python script. I also use NoteTab and have no problems
running text from NoteTab through the same Python script.

Any vimmers help with this?

I'm sending standard text with the vim command :%!sort.py

The Python script (sort.py) is:

from sys import stdin
input = stdin.read().split('\n')
input.sort()
print '\n'.join(input)

I get:

Traceback (most recent call last):
File "d:\python\sort.py", line 2, in ?
input = stdin.read().split('\n')
IOError: [Errno 9] Bad file descriptor

Thanks,

rd
 
A

Ant

BartlebyScrivener said:
Hello,

I'm sure this is my fault or some Windows snafu. But using gvim 7.0 on

It's a bug in Windows. Try doing "sort.py < test.txt" from the command
line, and you'll get the same error. Try "python sort.py < test.txt"
and it should work fine. Apparently cmd.exe can't pick up the
registered file extensions.
I'm sending standard text with the vim command :%!sort.py

You'll have to use :%!python sort.py to get the filter to work.
 
B

BartlebyScrivener

You'll have to use :%!python sort.py to get the filter to work.

Damn. I should've thought of that. Then again, why would I when sort.py
works fine from the windows commandline.

Thanks a lot! That does the trick.

rd
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,576
Members
45,054
Latest member
LucyCarper

Latest Threads

Top