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?

Vinn
  • 263
  • 2
  • 7
  • 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 https://emacs.stackexchange.com/a/13418 and https://emacs.stackexchange.com/q/58264. – Drew Mar 05 '23 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)`. – Oliver Knodel Mar 05 '23 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 05 '23 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 05 '23 at 21:50
  • 1
    The take away is that if you want to change `evil` key bindings, you should use `evil` keymaps. – phils Mar 05 '23 at 21:57

0 Answers0