0

In ansi-term, it automatically rebinds C-c to have the same keybindings as C-x. I want to turn this behaviour off, so I can access the keybindings I have behind C-c. (I know about C-c C-j, but that's too many keys for my taste.)

1

Substitute the key you prefer for C-c in the following call to term-set-escape-char in order to change the value of term-escape-char to some other key, and then unbind C-c from the term-char-mode keymap.

(eval-after-load "term"
  '(progn (term-set-escape-char ?\C-c)
          (define-key term-raw-map (kbd "C-c") nil)))

To send a literal C-c to the terminal, you would use your chosen key followed by C-c.

Similarly for the other term-char-mode bindings mentioned at
C-hig (emacs)Term Mode RET

Remember that this only affects char mode, so switching from line mode to char mode would still be C-c C-k even if switching from char mode to line mode was no longer C-c C-j. You can change line mode bindings in term-mode-map if need be.

  • You misunderstood what I meant. By default in ansi-term, Emacs rebinds C-c to C-x (more or less). So I can't access keybindings like e.g. C-c r, because it'll try to run C-x r instead. – Kahr Kunne May 1 '17 at 20:40
  • I didn't misunderstand, but I didn't include unbinding C-c after calling term-set-escape-char. I've added that. – phils May 1 '17 at 22:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.