My .vimrc file has filetype mappings for different filetypes such as :
autocmd FileType sh map gf ...
autocmd FileType ruby map gf ...
While rewriting a program from one language to another, I have 2 splits, one with shell and one with ruby. I would assume that "gf" would take on its mapping based on filetype. However, it can only hold one mapping at a time.
Is there any way to declare a mapping only for the existing buffer. I tried ":windo" and ":bufdo" but they work for all windows or buffers.
I couldn't find a way to have two mappings, so I tried a variation on this:
My examples
Several files each with separate mappings (c pc sql sh s) plus a basic .vimrc.
When I move between buffers I push an F key to reset the mappings. It's clunky but it works.
1 Like
Perhaps, my key combinations could map to a function in vim, that checks the filetype at runtime and then executes the code. Haven't done any plugin writing, but I guess I could try this out a little later if no other answer comes up.
---------- Post updated 06-09-10 at 10:30 AM ---------- Previous update was 06-08-10 at 07:41 PM ----------
I have found the answer.
:help map-local
for example:
:map <buffer> ,w /[.,;]<CR>