On 16/07/09 20:27, Ben Fritz wrote:
>
>
>
> On Jul 16, 12:23 pm, Edward Beach<[email protected]> wrote:
>> Is there a way to define mappings local to a diff window?
>>
>> I have some specific mappings that I would like enabled when I'm in
>> diff mode. Normally I would set this using map<buffer> but on some
>> occasions I have the buffer in one window and a diff of the buffer in
>> another. In the original buffer,&diff == 0 and in the diffed buffer
>> &diff == 1 so is there an easy way to enable a mapping specific to the
>> window containing the diffed buffer?
>>
>> Thanks!
>
> Almost there! Check out :help :map-<expr> for the final piece.
>
> The help may not make this clear, but it seems from experimentation
> that<buffer> and<expr> can be used together without trouble.
Yes. The reply quoted above may not make this clear, but mappings can be
buffer-local but not window-local; so the {rhs} itself has to test
whether we're in a diff window or not, and act differently according to
the result (maybe returning the {lhs} if we aren't).
But since I don't see an autocommand event to detect that a given window
has become a diff window, maybe the mapping should be global?
map <expr> <F4> (&diff?"osome stuff\e":"\<F4>")
Best regards,
Tony.
--
Nobody suffers the pain of birth or the anguish of loving a child in
order for presidents to make wars, for governments to feed on the
substance of their people, for insurance companies to cheat the young
and rob the old.
-- Lewis Lapham
--~--~---------~--~----~------------~-------~--~----~
You received this message from the "vim_use" maillist.
For more information, visit http://www.vim.org/maillist.php
-~----------~----~----~----~------~----~------~--~---