Tuesday, October 30, 2012

Re: What do I need to read to understand g: and s: VIM variable prefixes?

On Tue, Oct 30, 2012 at 8:09 PM, <hermitte@free.fr> wrote:
> Hello,
>
>> What do I need to read to understand g: and s: VIM variable prefixes?
>> This one is hard to guess for the built in help, and Google isn't
>> helping.
>
> Have you tried
> :h s:^D
> ?
> which will give you :h s:var
>

I had no idea that ^D would complete in :h! That's it, I'll never have
to post to the list again! :)


>> The root of the issue is trying to figure out why g:someVariable can
>> be seen in SomeFunction() but cannot be seen in s:AnotherFunction().
>
> someVariable in a function will be actually l:someVariable. When accessing global variables from functions, always prefix them with g:.
>
>
>> What is the s: for that precedes the second function's name, and why
>> does it change scope (s for scope, perhaps)? Thanks.
>
> s: stands for script. The scope of the variable is the script. As file static variables in C.
>

Thanks. Actually, since my first post I see that I did have a bug in
the function: reducing it to a most-simple case revealed the flaw. In
any case, what I have is a function in .vimrc that begins with s:,
something that was suggested to me on SuperUser, so I'd like to know
what it's doing, not just how to do it.

Thank you.


--
Dotan Cohen

http://gibberish.co.il
http://what-is-what.com

--
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

No comments: