Hello,
thanks for your answer to my previous question. Now I'm trying to do
something more complicated, i.e. communicating between the vim-user and
my perl-script. Is there any possibility to interact with the vim user
from a script, e.g. asking him some questions?
Say, I wrote the following perlscript called "testscript.pl", which when
invoked with either ":'<,'>!testscript.pl" or ":'<,'>B !testscript.pl"
takes the piece of selected text and writes it out into the file
"testappend":
#!/usr/bin/perl
open(OUT, ">>testappend");
@text=<>;
print OUT ("@text\n");
print ("@text");
close(OUT);
Now the new project is to ask the user some question and append the
answer to the file as well. My first idea was to add the following lines
to the perl script:
print("Add some comment? ");
$answer=<>;
print("*** $answer ***\n");
But this won't work of course, because the perlscript doesn't get back
to vim in order to collect more input.
Do you have any ideas how to tackle this problem? Input does not
necessarily have to take place from within vim - an extra shell window
would be fine too.
Best regards,
Harald
Harald Vajkonny schrieb:
>> There's the vis.vim plugin,
>> http://vim.sourceforge.net/scripts/script.php?script_id=1195
>>
>
> Thank you. This plugin is great! :)
>
> Regards,
> Harald
>
>
>
> Charles E. Campbell, Jr. schrieb:
>
>> Harald Vajkonny wrote:
>>
>>
>>
>>> Vissale NEANG schrieb:
>>>
>>> You can design your external script as a filter (:help filter) thus
>>> you can run your script on the selected text and it will be replaced
>>> by the result of the script.
>>>
>>> You can try with the "sort" program. Select your text then type the
>>> following command
>>>
>>> :'<,'>!sort
>>>
>>>
>>>
>>> I tried this and everything works fine for complete lines, but if I
>>> select only a word to be filtered/substituted, the whole line is
>>> affected by the filter anyway. Is there any workaround?
>>>
>>> ==================================================================
>>>
>>> Vissale NEANG schrieb:
>>>
>>> You can design your external script as a filter (:help filter) thus
>>> you can run your script on the selected text and it will be replaced
>>> by the result of the script.
>>>
>>> You can try with the "sort" program. Select your text then type the
>>> following command
>>>
>>> :'<,'>!sort
>>>
>>> 2007/8/10, Harald Vajkonny <[EMAIL PROTECTED]>:
>>>
>>>
>>>
>>>
>>>
>>>>> Hi,
>>>>>
>>>>> I would like to pass a piece of marked text as an argument to an
>>>>> external script. In return I would like to replace the selected original
>>>>> text with the output of that program. How should I pass arguments best
>>>>> between vim and shell?
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>
>>>
>>>
>>>
>> There's the vis.vim plugin,
>> http://vim.sourceforge.net/scripts/script.php?script_id=1195:
>>
>> [select text with visual mode]
>> :B !external_script_here
>>
>> Actually, any Ex command can be placed after the B. It works with
>> picking text using
>> visual-block and !sort, for example (ctrl-v, move, :B !sort).
>>
>> Dart
>>
>>
>>
>>
>>
>>
>
>
> >
>
>
--
"Wouldn't the sentence 'I want to put a hyphen between the words Fish
and And and And and Chips in my Fish-And-Chips sign' have been clearer
if quotation marks had been placed before Fish, and between Fish and
and, and and and And, and And and and, and and and And, and And and
and, and and and Chips, as well as after Chips?"
--~--~---------~--~----~------------~-------~--~----~
You received this message from the "vim_use" maillist.
For more information, visit http://www.vim.org/maillist.php
-~----------~----~----~----~------~----~------~--~---