Problematic behavior caused by mapping in matchit plugin

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Problematic behavior caused by mapping in matchit plugin

Efraim Yawitz
Hi,

The docs for the matchit plugin say that the mappings in it may cause strange behavior, but I think this example is worth noting.

I was trying to do yV% on lines like this:

#ifdef SOMETHING
...
#endif //SOMETHING

expecting to yank all the lines, but what I got was everything up to the comment, i.e., the last line had only the #endif.  A new uninstalled vim (without plugins) did what I had expected originally.

After some debugging, what I found was that in this mapping in matchit.vim:

onoremap <silent> %  v:<C-U>call <SID>Match_wrapper('',1,'o') <CR>

the 'v' in v:<C-U> was changing the operator to forced characterwise after my 'V' had tried to force it to forced linewise.  Doing ounmap % got the behavior I was looking for.

I couldn't find yet in the help what v:<C-U> is supposed to do, but what is significant is that the 'v' in that mapping is evidently being interpreted twice, once as a "force characterwise" signal, and again for what it 'really' means.  I imagine this could cause problems in other plugins as well which use this construction.

Ephraim

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

---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Problematic behavior caused by mapping in matchit plugin

Christian Brabandt

On Do, 11 Mai 2017, Efraim Yawitz wrote:

> Hi,
>
> The docs for the matchit plugin say that the mappings in it may cause strange
> behavior, but I think this example is worth noting.
>
> I was trying to do yV% on lines like this:
>
> #ifdef SOMETHING
> ...
> #endif //SOMETHING
>
> expecting to yank all the lines, but what I got was everything up to the
> comment, i.e., the last line had only the #endif.  A new uninstalled vim
> (without plugins) did what I had expected originally.
>
> After some debugging, what I found was that in this mapping in matchit.vim:
>
> onoremap <silent> %  v:<C-U>call <SID>Match_wrapper('',1,'o') <CR>
>
> the 'v' in v:<C-U> was changing the operator to forced characterwise after my
> 'V' had tried to force it to forced linewise.  Doing ounmap % got the behavior
> I was looking for.
>
> I couldn't find yet in the help what v:<C-U> is supposed to do, but what is
> significant is that the 'v' in that mapping is evidently being interpreted
> twice, once as a "force characterwise" signal, and again for what it 'really'
> means.  I imagine this could cause problems in other plugins as well which use
> this construction.

I believe this is the same issue as the one mentioned in the neovim
issue tracker:
https://github.com/neovim/neovim/issues/5691

I have tried to contact Benji, but unfortunately, he did not react.

Best,
Christian
--
Das Leben besteht in dem, was ein Mensch den ganzen Tag über denkt.
                -- Ralph Waldo Emerson

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

---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Problematic behavior caused by mapping in matchit plugin

'Jürgen Krämer' via vim_use
In reply to this post by Efraim Yawitz
Am 11.05.2017 um 18:52 schrieb Efraim Yawitz:

> Hi,
>
> The docs for the matchit plugin say that the mappings in it may cause
> strange behavior, but I think this example is worth noting.
>
> I was trying to do yV% on lines like this:
>
> #ifdef SOMETHING ... #endif //SOMETHING
>
> expecting to yank all the lines, but what I got was everything up to
> the comment, i.e., the last line had only the #endif.  A new
> uninstalled vim (without plugins) did what I had expected
> originally.
>
> After some debugging, what I found was that in this mapping in
> matchit.vim:
>
> onoremap <silent> %  v:<C-U>call <SID>Match_wrapper('',1,'o') <CR>
>
> the 'v' in v:<C-U> was changing the operator to forced characterwise
> after my 'V' had tried to force it to forced linewise.  Doing ounmap
> % got the behavior I was looking for.
>
> I couldn't find yet in the help what v:<C-U> is supposed to do, but
> what is significant is that the 'v' in that mapping is evidently
> being interpreted twice, once as a "force characterwise" signal, and
> again for what it 'really' means.  I imagine this could cause
> problems in other plugins as well which use this construction.

See :h o_v

An Ex-command used in Omap-mode  :<C-U>...<CR>  is an exclusive motion.
With   v:<C-U>...<CR>   it becomes inclusive.

It think it's a bug in Vim that
    Vv:<C-U>...<CR>
is kind of undefined yet (at least this was case quite some time ago ...).

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

---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.