On 07/01/09 04:50, pansz wrote:
> hengxing 写道:
>> Hi all!
>>
>> I wrote a function in my vim script like following:
>>
>> func Foo()
>>      let g:fn= "/tmp/aa.txt"
>>      return g:fn
>> endfunc
>> And at the same time, I wanted to create a 'map',
>> which can read the file content under cursor in  vim,
>> which filename is the Foo return.
>>
>> I've written like the following but it doesn't work:
>>
>> map kkk :call Foo()|read<cr>
>> How can I pass the result of Foo to the "read" command?
>>
>> Ps: I don't want to read the file in the Foo function, because
>> I want the method which can pass the functions return to
>> the Ex-command. Or tell me it can't implement for some reasons.
>>
>> Thanks!
>
> You can use something discussed in my previous thread:<C-R>=
>
> nmap kkk :<C-R>=Foo()<cr><cr>
>
> would do what you want.

not nmap but cmap since you want the mapping to be active on the 
command-line, after you type ":read ". Or else, if you always want to 
use the same function to generate the operand of the ":read" command, 
use ":execute" as follows:

        :map kkk :exe 'read' Foo()<CR>


Best regards,
Tony.
-- 
Finagle's Third Law:
        In any collection of data, the figure most obviously correct,
        beyond all need of checking, is the mistake

Corollaries:
        (1) Nobody whom you ask for help will see it.
        (2) The first person who stops by, whose advice you really
            don't want to hear, will see it immediately.

--~--~---------~--~----~------------~-------~--~----~
You received this message from the "vim_use" maillist.
For more information, visit http://www.vim.org/maillist.php
-~----------~----~----~----~------~----~------~--~---

Reply via email to