2011/1/13 ifys0325 <ifys0...@163.com>: > When you define a variable,it is userful only in this function. your > variable a#foo is not in the function a#FooFunc(). > > if you want define a global variable ,you can > > let g:a#foo = 1 > > if you only want this variable in this script .you can > > let s:a#foo = 1 > > and your fuction must be: > function! a#FooFunc() > "echo g:a#foo > echo s:a#foo > endfunction > > > > read help: > :h g:var > :h l:var > :h s:var > > > > 2011-01-13
Thanks for all your answer. :-) > ________________________________ > ifys0325 > ________________________________ > 发件人: winterTTr > 发送时间: 2011-01-12 22:57:34 > 收件人: vim_use > 抄送: > 主题: question about variable in autoload > 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 ?? > -- > 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 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 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