How to map (say) Ctrl-Shift-B

216 views
Skip to first unread message

DubiousDude

unread,
Dec 30, 2008, 4:58:30 PM12/30/08
to vim_use
In Vim's map command, <C-B> refers to control+B, while <S-B> refers to
Shift+B.
Is there a way to specify Ctrl-Shift-B? What about other combinations
other
than Ctrl+Shift e.g. Alt ?

Tony Mechelynck

unread,
Dec 31, 2008, 8:49:08 AM12/31/08
to vim...@googlegroups.com

IIUC, <S-B> -- or <S-b> -- is none other than B, i.e., capital B, which
you produce by hitting b with the Shift key depressed.

Ctrl-b and Ctrl-B are synonymous, they both mean 0x02. This cannot be
changed, it goes back to ASCII, which dates back to 7-hole paper tape
(not counting parity).

Alt-b and Alt-B are different, but here there's another hitch: Vim
represents the Alt modifier by setting the high bit (0x80), which means
that Alt-b (where b=0x62) is synonymous with ā (small-a-circumflex,
0xE2) and that Alt-B (where B=0x42) is synonymous with Ā
(capital-A-circumflex, 0xC2). Alt-Ctrl-B is 0x82 regardless of Shift,
since Ctrl-B is 0x02 regardless of Shift. In Latin1 0x82 is a
rarely-used control character but in Windows-1252 I think it is
printable, which means it might collide with some text character. In
Latin9 (aka ISO-8859-15) I think it's the same control character as in
Latin1 but I'm not sure.

For non-printable keys it is different: <F5> is the F5 key, <S-F5> is
Shift-F5, <C-F5> is Ctrl-F5, <A-F5> or <M-F5> is Alt-F5 (also known as
Meta-F5), <D-F5> is (on a Mac) Cmd-F5, <C-S-F5> is Ctrl-Shift-F5, etc.
Depending on your OS, it is possible that some of these combinations are
grabbed by the OS before they reach Vim: for instance, on my Linux
system with KDE winmanager, Alt-Fn and Ctrl-Fn are grabbed by the
windows manager and Ctrl-Alt-Fn is grabbed by the kernel, so gvim never
sees any of them. I can use Shift-Fn though.

See ":help keycodes", where these prefixes are near the end of the list.


Best regards,
Tony.
--
Valerie: Aww, Tom, you're going maudlin on me ...
Tom: I reserve the right to wax maudlin as I wane eloquent ...
-- Tom Chapin

Reply all
Reply to author
Forward
0 new messages