0

I want to bind a command to C-', C-` and C-0 through C-9 keys. It's not working in the terminal

Is there a way to do so?

zcaudate
  • 637
  • 4
  • 14

1 Answers1

0

The following works for me:

(define-key text-mode-map (kbd "C-9") #'next-line)

Or, with bind-key:

(bind-key (kbd "C-9") #'next-line)
Fran Burstall
  • 3,665
  • 10
  • 18
  • I'm hoping to use it with `bind-key` – zcaudate Sep 23 '18 at 10:53
  • @zcaudate Then you should have said so initially. (Sorry I can't help; I am unfamiliar with that command.) – Harald Hanche-Olsen Sep 23 '18 at 10:58
  • @HaraldHanche-Olsen I think it has to do with the fact that it's running inside the terminal. `M-1` works but not `C-1`. Is there a reason for this? – zcaudate Sep 23 '18 at 11:47
  • 1
    @zcaudate This is the correct answer to the question you asked, but it sounds like your actual question is https://emacs.stackexchange.com/questions/1020/problems-with-keybindings-when-using-terminal – npostavs Sep 23 '18 at 12:08
  • 1
    @zcaudate Yes, there is a reason, but it's kind of technical: Briefly, terminal emulators will transmit M-1 as an ESCape character followed by 1 (and similarly for other M-something combinations). But characters like C-f are transmitted like the letter f with the high order bits zeroed, which works fine for control-letter combinations. There isn't a similar convention for other characters combined with the control key, though, so they generally flat out don't work in a terminal. – Harald Hanche-Olsen Sep 23 '18 at 13:53