Re: Buffer-local unmap of global mapping
On 01/13/2013 04:49 PM, Andy Wokula wrote: 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). I run both the bufexplorer and vim-surround plugins, so I've had to work around the problem you describe. My current solution for the ``ds`` mapping is: augroup local_bufExplorer autocmd! autocmd BufEnter \[BufExplorer\] unmap ds autocmd BufLeave \[BufExplorer\] nmap ds PlugDsurround augroup END 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,...)). After thinking about this for a while, your idea seems to cover the problem cases for me. It's hard to pick a good name for the option, but I think the functionality fixes this problem. Michael Henry -- 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
Buffer-local unmap of global mapping
All, I've got several two-key global mappings for the CtrlP plugin: nnoremap C-PC-O :C-UCtrlPBufferCR nnoremap C-PC-P :C-UCtrlPCR [...] 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 SIDCtrlP nnoremap SIDCtrlPC-O :C-UCtrlPBufferCR nnoremap SIDCtrlPC-P :C-UCtrlPCR 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 -- 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
Re: Buffer-local unmap of global mapping
Am 13.01.2013 21:42, schrieb Michael Henry: All, I've got several two-key global mappings for the CtrlP plugin: nnoremap C-PC-O :C-UCtrlPBufferCR nnoremap C-PC-P :C-UCtrlPCR [...] 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 SIDCtrlP nnoremap SIDCtrlPC-O :C-UCtrlPBufferCR nnoremap SIDCtrlPC-P :C-UCtrlPCR 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