Monday, December 28, 2009

Re: this nmap and imap work, but the vmap does not

On Mon, Dec 28, 2009 at 11:01 AM, Ben Fritz wrote:
>
> On Dec 27, 9:46 am, Bee wrote:
>> Adding <esc> did allow it to work, but only on the last line of the
>> selection.
>>
>> How can the selection be passed on?
>
> Oops, I neglected that part.
>
> Your explicit visual-mode mapping works on every line because pressing
> ':' in visual mode automatically enters a range of '<,'> to your Ex
> command, which means to run the Ex command on the visual selection. I
> do not think you will be able to use <F5> in your mapping after all,
> without some logic to determine what mode you are in, in which case it
> would just be easier to explicitly specify the command in a visual-
> mode mapping.

You could make the "implementation" mapping be defined for visual
mode, then map normal-mode <F5> to V<F5> and insert mode <F5> to
<C-o>V<F5>, or something like that, but then using <F5> in normal or
insert mode would clobber the '< and '> marks. You could split out
the important part of the implementation into a cmap, and have normal,
insert, and visual all be mapped to something that gets into
command-line mode with the correct leading range, and then invokes
that cmap, but that's almost certainly more trouble than it's worth.
It's probably best to just define the map multiple times.

~Matt

--
You received this message from the "vim_use" maillist.
For more information, visit http://www.vim.org/maillist.php

No comments: