On Tuesday, August 12, 2014 9:50:48 AM UTC-5, ZyX wrote:
> >
> >autoload/hello.vim:
> >
> >>function! s:Hello()
> >> echo "hello, my name is xautjzd!"
> >>endfunction
> >
> >plugin/hello.vim:
>
> Functions defined with s: are only accessible with s: or <SID> within the file you defined it in. You must do one of the following:
>
> 1. Use global function name. Since you are using autoload/hello.vim this name should be hello#Hello or you will not have your function autoloaded. You may still take any name and load your function with :runtime.
> 2. Put s:Hello into the same file you defined :Hello.
> 3. Use expanded variant of function name alongside with loading this function manually with :runtime. Check out :h <SID>, it will tell you how to get the expanded variant.
>
Right, that too. I guess I should have paid more attention to the file
names.
You're using autoload wrong. If you are using autoload, you need to
define a global name that can be used by your plugin script, formatted
in a way that Vim expects so it can automatically find the correct
autoload script to source to define the function.
In your case, autoload/hello.vim should contain:
function hello#Hello()
echo "hello, my name is xautjzd!"
endfunction
and plugin/hello.vim should be:
command Hello call hello#Hello()
--
--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php
---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
No comments:
Post a Comment