Tuesday, November 1, 2011

Re: &diff and filetype

On 2011-11-01, Joachim Hofmann wrote:
> Hello,
>
> I want to set a mapping, only when a certain (Ruby-)-Filetype event appears.
> I got a script where the mapping is defined, the mapping is created,
> and it works.
> But I don't want this mapping to be defined when vim is in diff-mode.
> In my versioning system I start vim for viewing diffs with
> gview -d "%1" "%2"
>
> Problem: It seems that when the filetype is set, the diff mode is
> not set yet
> so asking in my filetype fired script:
> if &diff
> map x y
> ...
> does not solve the task, because &diff is 0 and is set to 1 later.
>
> How/where can I solve this condition-dependent mapping?

You can use the FilterWritePre or FilterWritePost autocommand event
to trigger an unmapping, e.g. something like this:

au FilterWritePre * if &diff && &ft == "ruby" | silent! unmap x | endif

Regards,
Gary

--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

No comments: