-
-
Notifications
You must be signed in to change notification settings - Fork 5.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Some mappings in insert mode fail #10324
Comments
One could argue that for |
Making mappings work the same way on different systems is good, you can take your setup to another computer and it will still work. That this may break some old mappings can be annoying, but perhaps we can argue that it was a bug that they worked? |
For me, this is ok as there's a workaround. Thx. |
@LemonBoy can we somehow put this into the documentation, that one needs to be explicit about modifiers? |
The problem with writing documentation is that one should have a clear picture of what works, what's supposed to be working and what's not. And at the moment I'm quite confused. Changing the key-handling code is quite some work because there's no automated testing and the probability of introducing regressions and angering users is quite high. Beside merging The GTK GUI does:
While the W32 GUI does:
At the moment there are still some small differences between the two GUIs (eg. for W32 Which sequence is the "correct" one? The GTK one is pretty similar but not identical to |
I'm sorry, but I think putting this into the documentation is wrong, because the behavior is wrong. For example, on a German keyboard, |
There are a few levels of simplifications behind the scenes, #7016 (comment) a similar inconsistency was noted and fixed by removing the extra We're back to the original question: what's the expected behaviour here? Do we want to add some more logic in the GUI layer to perform this translation? Do all the GUIs support this (looking at you, Motif)? What about the terminal? Coming up with an answer is the hardest part, writing the code is a piece of cake. |
I find this problematic, one reason being the variety of national keyboard layouts. For example pound ( On a Canadian (bilingual) keyboard the dollar sign keeps it place, but the pound sign is moved to AltGr+3. No shift needed. How to exchange configuration between users of these two layouts? Same problem for German and Swiss (both German and Swiss mode) layouts -- German has Regarding the There also superscript 2 and 3, which are sometimes entered as a combination of AltGr plus the corresponding base digit (e.g., on a German keyboard), but are entered as the unshifted and shifted first key on the digits row on a French (Belgium) keyboard. I know it's hard to find a rule for when an additional |
Right, so we cannot know by looking at the character we get whether it would have been different without the shift key. Thus we don't know if the shift key is extra information or is already included in the character. For ASCII uppercase letters we know, but for others it depends on the keyboard layout. Thus there should be a system API to tell us whether the shift modifier was used or not. This requires someone familiar with the API to figure this out, write the code and verify it actually works. |
I can't think of any character which would not be different if the same key is pressed with or without the shift key. Either they are letter-like symbols which change case, or shifted keys generate completely different symbols from unshifted keys. Making There is probably only one printable character on every keyboard where the notation of an additional shifting makes sense, and that's A combination of different modifiers is another story. There clearly can be a need to distinguish between In regards to combinations with ctrl and shift, I guess it comes down to how someone thinks about the base character. When I write mappings, for letter-like symbols (mostly Latin letters and German umlauts, in my case) I would distinguish between shifted and unshifted keys by including (And don't get me started on P.S.: It seems some of the comments in this issue did not get through to the mailing list. (Something I have also noticed for other Github issues lately.) So excuse me, if I don't always react in a timely manner. |
I can't think of any *character* which would not be different if the
I think you mean "printable character" here.
same key is pressed with or without the shift key. Either they are
letter-like symbols which change case, or shifted keys generate
completely different symbols from unshifted keys. Making `map <S-A>
...` equivalent to `map A ...` might make sense, but making `map <S-1>
...` equivalent to `map ! ...` (if one is working with a German or
similar keyboard layout) does not. And even less so does demanding a
`<S-°>` just because `°` is not an ASCII character.
There is probably only one printable character on every keyboard where
the notation of an additional shifting makes sense, and that's
`<space>`.
There are many more, considering there are dozens of different keyboard
layouts. Most printable characters have a key which will produce a
different character with shift, but not all of them. Space is just one
example. Tab is another one.
A combination of different modifiers is another story. There clearly
can be a need to distinguish between `<C-A>` and `<C-S-A>`. That's
fine, but how would a combination of ctrl and a printable symbol be
interpreted? On most English (US and British) keyboards `;` and `:`
share the same physical key. If we press `<Ctrl>+<:>` does this get
interpreted as `<C+S+;>`? Has a mapping to use this notation or
`<C+:>`? And what if you switch to a German layout? There `<;>` is
`<Shift>+<,>` and `<:>` is `<Shift>+<.>`. The need for `<...+S+...>`
in the notation would make a mapping defined with a German layout in
mind incompatible with an English layout.
In regards to combinations with ctrl and shift, I guess it comes down
to how someone thinks about the base character. When I write mappings,
for letter-like symbols (mostly Latin letters and German umlauts, in
my case) I would distinguish between shifted and unshifted keys by
including `-S-` in the mapping, especially because `<c-a>` and `<C-A>`
have always been equivalent in Vim script. But for `<Ctrl>+<(>` I
would not think "Hey, that's `<C-S-8>`." That's `<C-(>` in my mind.
And for `<Ctrl>+<°>` it's `<C-°>`, not `<C-S-^>` and not `<C-S-°>`.
(And don't get me started on `<C-[>` on a German keyboard. ;-) )
The processing of actually pressed keys to some character plus modifiers
is very much dependent on the system. Therefore we need the system to
tell us whether the shift key was used to change the character or not.
Anything else is guessing. We might be good at guessing...
…--
# echo reboot >universe
# chmod +x universe
# ./universe
/// Bram Moolenaar -- ***@***.*** -- http://www.Moolenaar.net \\\
/// \\\
\\\ sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ ///
\\\ help me help AIDS victims -- http://ICCF-Holland.org ///
|
Yes, "printable" makes it clearer about what characters I was talking.
I actually think of Tab more as a control code than as an actual printable character. And of course it makes sense (to be able) to distinguish between a combination of modifiers with
Yes, and the variety of different keyboard layouts is the reason why I think it's a bad idea to require the presence of |
Implementation uses additional call to ToUnicode() to recognize more precisely, what is going on concerning Alt, Crtl and Shift modifiers. ctrl+alt=altgr ============== Fixes: questionable PR vim#10308, (was blamed by @sthomen), recovering standard-Windows behavior In case both left Ctrl and Alt are hold, attempt is firstly made to translate keypress in the same way as AltGr was hold, and if translation differs from original (without Ctrl+Alt), effect is kept and both Ctrl and Alt modifiers are forcibly removed in _OnChar(). intelligent "unshifting" ======================== Fixes: vim#10324 Similarly, in case Shift is hold, attempt is firstly made to translate keypress in the way that Shift key effect is removed. If such translation differs from original (with Shift hold) - Shift modifier is assumed to be already accounted by translation, and _OnChar() is instructed to forcibly remove Shift modifier.
Implementation uses additional call to ToUnicode() to recognize more precisely, what is going on concerning Alt, Crtl and Shift modifiers. ctrl+alt=altgr ============== Fixes: questionable PR vim#10308, (was blamed by @sthomen), recovering standard-Windows behavior In case both left Ctrl and Alt are hold, attempt is firstly made to translate keypress in the same way as AltGr was hold, and if translation differs from original (without Ctrl+Alt), effect is kept and both Ctrl and Alt modifiers are forcibly removed in _OnChar(). intelligent "unshifting" ======================== Fixes: vim#10324 Similarly, in case Shift is hold, attempt is firstly made to translate keypress in the way that Shift key effect is removed. If such translation differs from original (with Shift hold) - Shift modifier is assumed to be already accounted by translation, and _OnChar() is instructed to forcibly remove Shift modifier.
Steps to reproduce
Expected behaviour
Both imappings should work.
Version of Vim
gvim 8.2.4847, 64-bit
Environment
Windows 7 64-bit,
Logs and stack traces
No response
The text was updated successfully, but these errors were encountered: