Stupid question, but: how to press C-(
(this is a default bind in Prelude Emacs for Smartparens's sp-backward-slurp-sexp
)? On my keyboard i have such bracket only in same key with 9
.
1 Answer
This is a convention when describing key bindings in text. C
indicates the control key, M
the meta key (the alt key on most keyboards), and S
indicates the shift key. The shift key is not normally listed explicitly. Instead, you would refer to the symbol that you get when holding the shift key.
For instance, the command set-mark-command
is bound to C-@
. To actually type this key, you would press C-S-2
. Or in your example, C-(
is entered by pressing C-S-9
. (this assumes you're using a US keyboard, where @
is on the 2
key, and (
is on the 9
)
One other note: for key combinations that combine the control key and a letter, the shifted letters do the same thing as the unshifted letter by default. That is, C-S-a
(C-A
) is the same as C-a
. The same is true for meta. Meta + a shifted letter (eg. M-S-a
) does the same as meta + the unshifted letter (e.g., M-a
).
However, if you wish you can change this by explicitly binding the shifted letter to a different command. See the manual section (emacs) Modifier Keys for more details on this.
Finally, note that all of this is in reference to how we communicate about key bindings. As @KaushalModi points out, when it comes time to actually make a keybinding in your init file, you don't include the S-
, you actually enter the shifted key. That is, you use
(kbd "C-(")
and not
(kbd "C-S-9")
-
1I'd like to add that the convention is to use
S
when doing something like Ctrl + Shift + <alphabet>. So in the case of "Ctrl + Shift + p", it would be(kbd "C-S-p")
. So rather than remember rules when to use or not useS
in the bindings, it's better to just doC-h c
(orC-h k
) followed by the key combination you are interested in binding, to get the correct key notation. Apr 8, 2016 at 20:48 -
-
@KaushalModi actually, for Ctrl + letter, it doesn't matter if you use
S-
or not, captials and lower case letters are always treated the same. I didn't realize that before!– TylerApr 8, 2016 at 21:04 -
Hmm, but I do have
M-f
andM-F
bound to different things and they call different commands as I would expect. Apr 8, 2016 at 21:07 -
3You CAN bind
C-A
andC-a
to different commands; just thatC-A
is the wrong representation;C-S-a
is the right one. Try out(global-set-key (kbd "C-S-n") #'previous-line)
inemacs -Q
;C-n
will donext-line
butC-S-n
("C-N") will doprevious-line
. Apr 8, 2016 at 21:21
C-(
is the same asC-S-9
C-h c
followed by the key combination you need to bind something to. If something is already bound, you will see that that is, or you will simply see that that combination is not bound to anything. For example, if you doC-h c
followed by Ctrl+Shift+9 in anemacs -Q
session, you will seeC-( is undefined
. So you need to bind your command to(kbd "C-(")
.