Ctrl+/ has the same effect as BackSpace because your terminal tells Emacs that you pressed Backspace: it sends DEL
for Ctrl+/. There's no character for C-/
and most terminals don't have a control sequence for it, so there's no chance that Emacs would see C-/
. You need to reconfigure the terminal to either send a different escape sequence that you bind to undo
in Emacs, or send C-_
when you press Ctrl+/. The second approach is a lot easier, but I'll also show the first approach in case you want redo
as well.
Follow the steps described in the Arch Wiki to create a custom keymap for the Linux console. (Well, not to the letter — I guess you won't run vim
.) Check which keymap is the current one by locating the line KEYMAP=…
in /etc/vconsole.conf
. Open the file /usr/share/kbd/keymaps/KEYMAP.map.gz
where KEYMAP
is the keymap name. Save it as /usr/local/share/kbd/keymaps/astrofloyd.map
. In /etc/vconsole.conf
, replace the line KEYMAP=…
by KEYMAP=astrofloyd
.
The next time you reboot, you'll be using your own keymap. You can load it immediately with loadkeys astrofloyd
. You need to run this command whenever you change the .map
file.
In astrofloyd.map
, locate the line for the slash key. It's keycode 53, sending slash question …
or U+002f U+003f …
depending on how the information is presented. If you see
keycode 53 = U+002f U+003f U+0323 U+002e Delete Delete …
then the columns to the right of the equal sign are, respectively: bare key, Shift, AltGr, AltGr+Shift, Ctrl, Ctrl+Shift, Ctrl+AltGr, Ctrl+AltGr+Shift, Meta, etc. So change Delete
in the 5th and 6th column after the equal sign to Control_underscore
.
If you see a line with
control keycode 53 = Delete
then change Delete
to Control_underscore
there.
If you want Ctrl+Shift+/ to do redo
, you'll need to bind it to a different escape sequence. The Linux console has limited support for escape sequences. You need to use a known keysym name, and the only ones that don't have a conventional meaning are F25
, F26
, etc. So pick one, e.g.
keycode 53 = U+002f U+003f U+0323 U+002e Control_underscore F25 …
string F23 = "\033[27;6;63~"
and let Emacs know about the control sequence that it sends.
(define-key input-decode-map "\e[27;6;63~" [?\C-\?])
(global-set-key [?\C-\?] 'redo)