On Tue 5-Dec-06 12:56pm -0600, Alan G Isaac wrote: > 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.
Interesting. I changed my simply test to map <buffer> <unique> <c-a> :echo 'It worked!'<CR> and had no problem. My first thought was that you may be sourcing twice (such as an autocmd performing 'setl ft=tex', but then I read on. > 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? I don't see that behavior. The :bd appears to clear both buffer local mappings and variables - as it appears to say in the docs. -- Best regards, Bill