2

After trying to define a custom binding:

(global-set-key (kbd "g l") 'evil-end-of-line)

I get:

(error Key sequence g h starts with non-prefix key g)

because g is the start of navigation for many commands in evil.

How can I make it use my binding (which isn't bound to any other command: g l) whilst keeping evil's prefix binding?

Since g is the prefix for other evil commands, I'm unable to use it with another combo. I still want to keep other g <key> commands like g g

3
  • Please clarify: You want g to both (1) perform navigation as soon as you hit it and (2) wait for you to hit l and then invoke evil-end-of-line instead? You could perhaps use sit-for and after that delay (i.e., if no user input) then use the usual g command, else, if l is hit within that delay use your eol command.
    – Drew
    Commented Apr 29, 2020 at 16:40
  • @Drew g is the start of navigation for many commands in evil. So I want to use the combination that isn't bound to any other command: g l. But because g is the prefix for other evil commands, I'm unable to use it with another combo. I still want to keep other g ... commands like gg without a delay.
    – mustaqim
    Commented Apr 30, 2020 at 5:16
  • Please put such clarifying info in the question itself. Comments can be deleted at any time. Thx.
    – Drew
    Commented Apr 30, 2020 at 15:06

1 Answer 1

5

You're manipulating the wrong map:

(with-eval-after-load 'evil
  (define-key evil-motion-state-map (kbd "g l") 'evil-end-of-line))
1
  • Thank you! Just for completeness, this is it set in Doom Emacs: (map! :n "g l" 'evil-end-of-line)
    – mustaqim
    Commented Jun 21, 2023 at 4:22

Your Answer

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

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