On 06/23/2010 01:47 PM, Ben Fritz wrote:
>
>
> On Jun 23, 11:30 am, AK <[email protected]> wrote:
>>
>> It does work here, vim7.2, ubuntu 9.10. If I add the inputdialog after
>> the if block, and source the file, it doesn't show up. If I do :unlet
>> b:script_loaded and then source again, it does show up. If I source yet
>> again, it stops showing up.
>
> Yes, but if you just enter the ":new" command to open a new buffer,
> your script will load.

That's the thing that I didn't realize. I thought plugins only load on
startup of vim.

>
> b:... variables are local to the buffer. Creating a new buffer will
> mean that the b:... variable you defined will not exist in the new
> buffer and your script will potentially load again.
>
> I'm a little worried that you're developing a plugin without basic
> knowledge of variable scope in Vim.

I'm using g: vars everywhere myself, that bit of code I got from a well
known plugin (I don't remember which), so I just put it in since it
seemed clear what it does.

You're right though that there's still a lot I don't know and I should
probably have read up on variable scope..

> I highly suggest reading through :help internal-variables before you
> go any further in your plugin development.

Will do!

>
> Unless, of course, you're intentionally defining a buch of BUFFER-
> LOCAL mappings, commands, etc. in which case you would want to use a
> buffer-local variable to determine whether the script is loaded.

I am defining some buffer mappings using :nnoremap <buffer> ... and that
seems to work as expected so far.

   -ak

-- 
 Python plugins for vim: outliner, todo list, project manager, calendar,
 expenses tracker, sortable table, and more |
 http://lightbird.net/pysuite/


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

Reply via email to