Am 13.01.2013 21:42, schrieb Michael Henry:
All,

I've got several two-key global mappings for the CtrlP plugin:

   nnoremap <C-P><C-O> :<C-U>CtrlPBuffer<CR>
   nnoremap <C-P><C-P> :<C-U>CtrlP<CR>
   [...]

These mappings interact with plugins that provide buffer-local
mappings that are prefixes of these multi-key mappings.  For
example, the Tagbar plugin defines a normal-mode buffer-local
mapping for CTRL-P.

The problem is that when I press CTRL-P in the Tagbar window,
Vim assumes that it might be the prefix for the global mappings
for CtrlP, so it waits for 'timeoutlen' before deciding to
invoke the single-key buffer-local mapping for Tagbar.  Because
my preferred 'timeoutlen' is three seconds, this renders the
buffer-local mapping essentially useless for me.

My current work-around is to map the key CTRL-P to a prefix,
then combine that prefix with other keys to make the final
mappings, something like this:

   nmap      <C-P>             <SID>CtrlP
   nnoremap  <SID>CtrlP<C-O>   :<C-U>CtrlPBuffer<CR>
   nnoremap  <SID>CtrlP<C-P>   :<C-U>CtrlP<CR>

This way, Vim won't see any multi-key mappings that begin with
CTRL-P, so a buffer-local mapping of CTRL-P will execute without
waiting for 'timeoutlen'.

Is there a better way to handle this problem in general?  I
don't see a way to "unmap" the global mappings on a per-buffer
basis, and I'd like to keep the global mappings in-place for
most buffers while Tagbar is running so globally unmapping when
Tagbar opens and restoring when it closes doesn't quite fit the
bill, either.

Thanks,
Michael Henry

I don't have an answer, I think what you tried is the best you can get
so far.

But I agree, a general solution would be useful!

Several plugins (buffer explorers, file explorers) define a lot of short
keys (keys like `d' or `y'), but it's awkward to use them because they
often wait for a longer global sequence (e.g. `ds', `ys' from
surround.vim).

First idea: add a new buffer-local option that, when enabled, means:
    Only check buffer-local mappings (not global mappings) when waiting
    for a complete left-hand-side.

Using an option, the mechanism could be turned on and off (how would I
otherwise access a global mapping?);
(this is opposed to a new mapping modifier (next to <buffer>, <silent>,...)).

--
Andy

--
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

Reply via email to