0

I have a problem with following key binding:

(global-set-key (kbd "C-/") 'comment-or-uncomment-region)

Actually, it is ignored by Emacs so undo is executed instead. I'm running Emacs in gui mode.

  • 1
    Do you have any minor-modes active such as undo-tree, which would override global bindings? Type M-x describe-key or C-h k and then your keyboard shortcut and verify that the actual function being called is exactly undo or something else. Also, check your *Messages* buffer for error messages after starting Emacs -- an error in the init file can cause Emacs to stop loading the file once it reaches that particular point. – lawlist Nov 27 '17 at 18:47
  • It works for me. Do you see the same thing if you start Emacs using emacs -Q (no init file)? If not, recursively bisect your init file to find the culprit. – Drew Nov 27 '17 at 18:51
  • Yes, i have undo tree. – dev1223 Nov 27 '17 at 19:18
  • Not sure what's causing this, but maybe Emacs is not-so-subtly telling you to just use the M-; binding which does what you want by default already. – Stefan Nov 28 '17 at 13:40
1

Thanks to describe-key, I found that / is interprpeted as a <kp-divide>, so this keybind is working like a charm now. (thanks lawlist)

(global-set-key (kbd "C-<kp-divide>") 'comment-or-uncomment-region) 

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.