Reply to message «question about variable in autoload», 
sent 17:27:42 12 January 2011, Wednesday
by winterTTr:

Yup, I ran in this problem some time ago, asked about it somewhere on vim-dev, 
and got the answer that the reason is just the same as with the following code:

    let foo=1
    function Foo()
        echo foo
    endfunction
: vim does not have any varibles without some `C:' prefix. When you use 
unprefixed variable outside of any functions, `C:' is assumed to be `g:' (so, 
variables are global). If you use it inside some function, `C:' is assumed to 
be 
`l:' (so, variables are local to function). Thus, `a#foo' variable is really 
`g:a#foo' in its definition (since it is outside of a function) and `l:a#foo' 
in 
a function (and so is undefined).

Original message:
> I have a script such a.vim in autoload directory, and the file content
> is as below:
> ----------------begin-----------
> let a#foo = 1
> 
> function! a#FooFunc()
>       echo a#foo
> endfunction
> -----------------end-------------
> 
> But when i call this function with command
> 
> :call a#FooFunc()
> 
> I always get the error
> "
> E121: Undefined variable: a#foo
> E15: Invalid expression: a#foo
> ".
> 
> 
> I can use ":echo a#foo", and there is no error and display "1" on the
> command line.
> Why does the error "undefined variable" come out when i use it in a
> autload function ??

Attachment: signature.asc
Description: This is a digitally signed message part.

Reply via email to