On Mon 4-Dec-06 6:54pm -0600, you wrote:
> On Mon, 4 Dec 2006, Bill McCarthy wrote:
>> On Mon 4-Dec-06 5:56pm -0600, C.G.Senthilkumar. wrote:

>>> I use the following autocmd in my ~/.vimrc to load a source file with my
>>> personal vim mappings while editing a tex file:
>>>
>>> autocmd FileType tex source ~/Dot.vilatexrc
>>>
>>> This works fine. However, the mappings continue to exist even after I
>>> open a different filetype without restarting vim. Is there an "unsource"
>>> command? If yes, how do I tell vim to do that each time I open another
>>> filetype.

>> You could make those mappings local.  When you delete a
>> buffer with local mappings, those mappings are cleared.
>>
>> See :help map-local

> :help map-local
>                                  *:map-local*
> *:map-<buffer>* *E224* *E225*
> If the first argument to one of these commands is "<buffer>" it will apply to
> mappings locally to the current buffer only.  Example: >
>          :map <buffer>  ,w  /[.,;]<CR>
> ...
> ----------------
>
> What does the <buffer> mean?
> Is it a literal string or the name of the file I'm editing or something
> else?

It is a type of map it this context.  The map will only
apply to the current buffer.  When you read a file into a
buffer, for example, the file type is set which triggers the
FileType event.  There are examples given of such a map.
I'll give another below.

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>

Now edit a tex file and try <c-a>.  Moving to another window
not containing a tex file and <c-a> has its normal behavior.

-- 
Best regards,
Bill

Reply via email to