<C-+> - impossible on german keyboard layout under linux ?

261 views
Skip to first unread message

haron

unread,
Feb 4, 2008, 6:43:06 PM2/4/08
to vim_use
Hi, All,

I am hooked since 3 years on windows gvim mapping for jump a tag
using <C-+> shortcut ("+" on German keyboard is located exactly
where "]" is on English keyboard). Under linux neither GUI nor
console versions are able to work this way for me - <C-+> isn't
just recognized by vim|gvim(|xterm?) at all.

Not sure, is this issue is purely vim related / vim related at
all. Post here is done in the hope that some German (Swiss?
Austrian?) vim'ers are successfully solved this problem already.
Still remains (as very possible reason for my troubles) the option
of just somehow misconfigured Xorg.

Googling for that everything what I find was:
http://vim.wikia.com/wiki/VimTip100 - with the suggestion to use
umlaut ü for jumping (interesting but not in conformance with my
windows experience). Of course, it seems to be that remapping of
flat "+" in normal mode will be a solution for me, but than I
lose (theoretically) some existing mappings for just "+" in some
future extensions / plugins.

Cases examined:

---------------
Working as desired case a)
german keyboard layout, Windows XP

$ gvim
a<C-V>+<C-V><C-+>

produces:

+^]

---------------
Not working as desired case b)
German keyboard layout, OpenSUSE10.3 / KDE

$ gvim
a<C-V>+<C-V><C-+>

produces:

++

---------------
Not working as desired case c)
German keyboard layout, OpenSUSE10.3 / KDE

$konsole | $xterm
$vim
a<C-V>+<C-V><C-+>

produces:

++

---------------
Not working as desired case d)
German keyboard layout, OpenSUSE10.3 / KDE

$konsole | $xterm
cat -v
+<C-+>

produces:

++

---------------

Or should I just live with impossibility of distinguish between
'+' and <C-+> under linux ?

-haron

Tony Mechelynck

unread,
Feb 5, 2008, 5:12:46 AM2/5/08
to vim...@googlegroups.com
haron wrote:
> Hi, All,
>
> I am hooked since 3 years on windows gvim mapping for jump a tag
> using <C-+> shortcut ("+" on German keyboard is located exactly
> where "]" is on English keyboard). Under linux neither GUI nor
> console versions are able to work this way for me - <C-+> isn't
> just recognized by vim|gvim(|xterm?) at all.
>
> Not sure, is this issue is purely vim related / vim related at
> all. Post here is done in the hope that some German (Swiss?
> Austrian?) vim'ers are successfully solved this problem already.
> Still remains (as very possible reason for my troubles) the option
> of just somehow misconfigured Xorg.
>

Ctrl-+ is not defined reliably in ASCII: when x is a printable key, Ctrl-x is
defined as follows:

x and 0x1F if 0x40 <= x <= 0x5F
Ctrl(upcase(x)) if x is a lowercase letter
0x7F if x is a question mark (0x3F)
undefined otherwise

However, Ctrl-x (on various natyional keyboards other than US-QWERTY) does not
always mean "hold Ctrl and hit x": the ctrl-key code doesn't always follow the
unshifted key code, depending on how the national keyboard is mapped.

Jumping to a tag is Ctrl-] which might be anywhere on various national
keyboards, including "hold Ctrl and hit +" but Vim still sees it as Ctrl-]
(0x1D), so you should use <C-]> in the {rhs} of your mapping in order to map
it, regardless of which keys are used to produce it.

Best regards,
Tony.
--
A bug in the hand is better than one as yet undetected.

haron

unread,
Feb 5, 2008, 9:09:40 AM2/5/08
to vim_use
> Jumping to a tag is Ctrl-] which might be anywhere on various national
> keyboards, including "hold Ctrl and hit +" but Vim still sees it as Ctrl-]
> (0x1D), so you should use <C-]> in the {rhs} of your mapping in order to map
> it, regardless of which keys are used to produce it.

But what should I use on the left part ? It is clear for me, that
command to map must be something like ":nmap {lhs} <C-]>". But
what the hell must I use as {lhs} ? This dosen't not works:

:nmap <C-+> <C-]>

This does

:nmap + <C-]>

, but than I can't use 'just "+"' in Normal mode any
more (of course, seems not be really very useful, but still
somehow "durty" solution).

Additionally, i have just realized, <C-ü> isn't recognized from
flat ü as well (related to another useful mapping to leave insert
mode using <C-[>, which in turn is somehow mapped on Windows to
<C-ü> on German keyboard).

Just one more experiment:
$xev <C-+> +
output is differs only as following:

--- ctrl-plus.txt 2008-02-05 15:09:15.000000000 +0100
+++ just-plus.txt 2008-02-05 15:08:59.000000000 +0100
@@ -1,14 +1,14 @@

KeyPress event, serial 31, synthetic NO, window 0x3000001,
root 0xbf, subw 0x0, time 3922598292, (165,-8), root:(169,794),
- state 0x14, keycode 35 (keysym 0x2b, plus), same_screen YES,
+ state 0x10, keycode 35 (keysym 0x2b, plus), same_screen YES,
XLookupString gives 1 bytes: (2b) "+"
XmbLookupString gives 1 bytes: (2b) "+"
XFilterEvent returns: False

KeyRelease event, serial 31, synthetic NO, window 0x3000001,
root 0xbf, subw 0x0, time 3922598360, (165,-8), root:(169,794),
- state 0x14, keycode 35 (keysym 0x2b, plus), same_screen YES,
+ state 0x10, keycode 35 (keysym 0x2b, plus), same_screen YES,
XLookupString gives 1 bytes: (2b) "+"
XFilterEvent returns: False

Tony Mechelynck

unread,
Feb 5, 2008, 1:38:24 PM2/5/08
to vim...@googlegroups.com
haron wrote:
>> Jumping to a tag is Ctrl-] which might be anywhere on various national
>> keyboards, including "hold Ctrl and hit +" but Vim still sees it as Ctrl-]
>> (0x1D), so you should use <C-]> in the {rhs} of your mapping in order to map
>> it, regardless of which keys are used to produce it.
>
> But what should I use on the left part ? It is clear for me, that
> command to map must be something like ":nmap {lhs} <C-]>". But
> what the hell must I use as {lhs} ? This dosen't not works:
>
> :nmap <C-+> <C-]>
>
> This does
>
> :nmap + <C-]>
>
> , but than I can't use 'just "+"' in Normal mode any
> more (of course, seems not be really very useful, but still
> somehow "durty" solution).
>
> Additionally, i have just realized, <C-ü> isn't recognized from
> flat ü as well (related to another useful mapping to leave insert
> mode using <C-[>, which in turn is somehow mapped on Windows to
> <C-ü> on German keyboard).
>

On the left side, you should use any keycode that Vim can identify when your
keyboard sends it, and preferably something which doesn't collide with an
existing Vim command. I recommend the F keys with or without Shift as the most
likely candidates.

Due to the way Vim uses "cooked" keyboard input (and also to the ASCII
representation of control keys), Ctrl + printable key is only reliably seen if
the "printable key" is one of
?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]abcdefghijklmnopqrstuvwxyz though on keyboards
other than US-QWERTY some of the "Ctrl + nonalphabetic printable key"
combinations may be strangely located or nonexistent (and as said in a
previous post, Ctrl + uppercase letter and Ctrl + lowercase letter are
equivalent).

Among these Control keys, Ctrl-[ is equivalent to Esc, Ctrl-I is equivalent to
Tab, Ctrl-M is equivalent to Enter. However, Shift-Tab is different from
Ctrl-Shift-I (which is Tab), Ctrl-Enter is different from Ctrl-M (which is
Enter, even when using both Ctrl keys), etc.

To check if a given keystroke is "seen" by Vim, hit it in Insert mode,
preceded by Ctrl-V (to see the keycode) or by Ctrl-K (only for a nonprinting
key or key combo, to see the <> code if any). In gvim many keys produce the
same result in both cases. (And if Ctrl-V is the paste key because you used
mswin.vim, which I don't recommend, then use Ctrl-Q instead.)


Best regards,
Tony.
--
ARTHUR: Right! Knights! Forward!
ARTHUR leads a charge toward the castle. Various shots of them battling on,
despite being hit by a variety of farm animals.
"Monty Python and the Holy Grail" PYTHON (MONTY) PICTURES LTD

haron

unread,
Feb 6, 2008, 2:47:07 PM2/6/08
to vim_use
On 5 фев, 19:38, Tony Mechelynck <antoine.mechely...@gmail.com> wrote:
> On the left side, you should use any keycode that Vim can
> identify when your keyboard sends it, and preferably something
> which doesn't collide with an existing Vim command. I recommend
> the F keys with or without Shift as the most likely candidates.

Is there a way i can learn my Xorg to produce some unique keycode
by pressing <C-+> instead of just sending '+', still sending '+' if
'+'
is pressed without Control modifier ?

(Hardware itself definitely isn't an issue because if I have "en"
keyboard layout active, <C-+> produces ^] = 0x1d keystroke
happily. In this case of course pressing just '+' produces ']').

Yet another attempt:
$echo 'keycode 35 = 0x5d 0x5d 0x2b 0x7e' > ~/.xmodmaprc
$xmodmap ~/.xmodmaprc

redefines + key to send following things where:

0x5d = ] by just pressing
0x5d = ] by pressing when shift is hold
0x2b = + when the Mode_switch key is used
0x7e = ~ when both the Mode_switch and Shift keys are used

This remap brings me the desired behaviour concerning ^] - if I
press + in insert mode it produces ']', <C-+> produces '^]', but
obviously I can't print '+' sign any more !

So, it's clear to me that my question is really rather Xorg /
Linux related, than vim-specific. The reason why I'm still asking
here is that here its more likely a place to find some peoples
who need from time to time keystroke "^]" at all :)

- haron
Reply all
Reply to author
Forward
0 new messages