0

In my emacs, tide-mode has a key for jump-to-definition of g d

I would like to define keys like this where i do not need a prefix (I use evil, so it would be in normal mode).

When I try this:

(global-set-key (kbd "g c c") 'comment-or-uncomment-region)

I get the message: Key sequence g c c starts with a non-prefix key

Is this possible?

5
  • It's not clear what you're asking. The message is telling you that g or g c is not a prefix key. See define-prefix-command. See also emacs.stackexchange.com/a/13418 and emacs.stackexchange.com/q/58264.
    – Drew
    Mar 5, 2023 at 17:10
  • 1
    You can define the key combo in evil-motion-state-map: (define-key evil-motion-state-map (kbd "gcc") 'comment-or-uncomment-region). Mar 5, 2023 at 19:24
  • Yes that worked for me. I am curious why the evil map allows keybindings without a prefix, while the global key map does not.
    – Vinn
    Mar 5, 2023 at 19:27
  • The global map does allow that (or rather, there's nothing preventing that in general for any keymap). But g is already bound to a command in the global map, therefore (as the error tells you) it cannot also be a prefix.
    – phils
    Mar 5, 2023 at 21:50
  • 1
    The take away is that if you want to change evil key bindings, you should use evil keymaps.
    – phils
    Mar 5, 2023 at 21:57

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.