On Mon, 4 Dec 2006, Bill McCarthy apparently wrote: 
> Instead of using an autocmd, you could place those maps in a 
> file called tex.vim in your local ftplugin directory.  Place 
> this single line in such a file: 
>     map <buffer> <c-a> :echo 'It worked!'<CR> 

OK, I did this.
But there is still a problem.

Suppose I have defined::

    imap <buffer> <unique> ;fn %<cr>\footnote{%<cr>}<cr>%<esc>-i

in my tex_ai.vim file in my local ftplugin directory.
I create the buffer ``:e c:\temp.tex``
then I leave the buffer by deleting it ``:bd``
and then later I decide to reopen it ``:e c:\temp.tex``.
Now I get a bunch of E227 errors, saying the mapping already 
exists.  This must mean that there Vim tries to redefine the 
mapping.

BUT I had tried to rule this out: at the top of my plugin 
I have::

    if exists("b:loaded_tex_ai")
            finish
    endif
    let b:loaded_tex_ai=1

But of course ``b:loaded_tex_ai`` is gone once I use ``:bd``.
But the mappings are apparently still around!
I do not really understand the variable convetions.
Should I have created ``s:loaded_tex_ai`` instead?
Might that work?

The problem does not arise if I use ``:bw`` instead of ``:bd``.
But then I lose other information too.

What is the right way to manage this?
Hints or suggestions?

Thank you,
Alan Isaac



Reply via email to