0

I've recently started using emacs and wanted to customize the editor. So, I've tried to rebind certains keys, but It's doesn't to work no matter what I do.

(global-unset-key (kbd "C-c") )
(global-set-key (kbd "C-c") 'forward-char)

In c++-mode, It keeps adding comments. Why is that? And how can I rebind the key effectively?

  • 1
    Welcome to emacs.stackexchange.com. Major-mode keymaps trump / supersede global keymaps. Type `C-h k` and then the keyboard shortcut to see what function is bound. Here is a write-up by Zah Lee: http://ergoemacs.org/emacs/emacs_set_keys_for_major_mode.html There are likely existing answers on emacs.stackexchange.com that may address these issues .... E.g., `(define-key c++-mode-map [C-down-mouse-1] 'rtags-find-symbol-at-point)` You may wish to Google: **emacs "define-key" "c++-mode-map" "emacs.stackexchange.com"** – lawlist Jan 19 '20 at 22:23
  • See [Active keymaps](https://www.gnu.org/software/emacs/manual/html_node/elisp/Active-Keymaps.html#Active-Keymaps) in the Emacs Lisp manual. – NickD Jan 20 '20 at 00:33
  • See also https://emacs.stackexchange.com/questions/42164/convention-about-using-c-x-or-c-c-as-prefix-keys - – Ian Jan 20 '20 at 09:06
  • See also https://stackoverflow.com/questions/59682728/how-to-create-emacs-key-bindings-for-interactive-org-mode-functions-org-mode-c/59698884?noredirect=1#comment105781835_59698884 - the question (and answer) is *very* similar. – NickD Jan 20 '20 at 12:52
  • @lawlist you should post that as an answer – Jordon Biondo Jan 21 '20 at 18:54

0 Answers0