On 10/12/2009 08:33 AM, Bram Moolenaar wrote:
>
> Michael Henry wrote:
>
>> I'd like to advocate the deprecation of the use of :vmap
>> command [...] This leads to unintended interference with
>> Select mode's defined behavior, which is especially
>> noticeable with "snippets" plugins (such as UltiSnips) that
>> use select mode extensively.

> Did you read  :help Select-mode-mapping  ?
> When a :vmap is used in Select mode Vim temporarily switches
> to Visual mode.   Quite often this works as expected.

Yes, I read that section of the help.  For those cases where a
:vmap is appropriate, Vim's switching from Select mode to Visual
mode does indeed ensure things work as expected, such that a
single right-hand side works for both Visual and Select modes.
I think it's OK to have Select-mode mappings for non-printable
characters, in which case :vmap could be appropriate (such as
for mapping CTRL-C to copy to the clipboard).

However, I'm advocating that :vmap should not be used to map
printable characters, as it interferes with the user's
fundamental expectations of Select-mode behavior.  Select mode
and Visual mode are different and have different purposes, so
it's reasonable that they might not always have the same
mappings.

For example, the popular matchit plugin uses :vnoremap as
follows:

vnoremap <silent> %  :<C-U>call <SID>Match_wrapper('',1,'v') <CR>m'gv``

This has the undesirable effect of creating a Select-mode
mapping for the "%" character, which breaks the user's
expectation that pressing "%" should delete the selection and
insert a "%" character.

For plugins like UltiSnips, the user is prompted with some
default text highlighted in Select mode.  If the user presses
<Tab>, the text is kept and the cursor jumps to the next
"tabstop"; to override the default text, the user simply types
the new text.  This works well unless printable characters are
mapped in Select mode, in which case the user can end up quite
surprised (for example, by pressing "%" and finding that the
cursor has jumped unexpectedly due to the matchit plugin's
Select-mode mapping).

I'm proposing that the documentation make a strong statement
deprecating the use of :vmap for printable characters (and only
printable characters).  The statement would need to carefully
explain the negative effects of :vmap with printable characters,
and contrast this with appropriate use cases for :vmap.

Michael Henry


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

Reply via email to