I'm using spacemacs and I've added the following user config:

(defun dotspacemacs/user-config ()
  "Configuration function for user code.
This function is called at the very end of Spacemacs initialization after
layers configuration.
This is the place where most of your configurations should be done. Unless it is
explicitly specified that a variable should be set before a package is loaded,
you should place your code here."
  (global-set-key (kbd "s-right") 'end-of-line)
  (spacemacs/set-leader-keys "fd" 'ac-php-find-symbol-at-point)   ;goto define

However, s-right doesn't seem to do what I want. What I want is when I press CMD + arrow-right it should jump to the end of the line.


Are you aware that in (kbd "s-right") the s means the Super key, not the Shift key?

And are you aware that the right-arrow key is written <right>, not right?

For example, Shift + right arrow would be (kbd "<S-right>"). You can see this by using C-h k and hitting the key sequence.

  • I think with CMD + arrow-right in the question text, they do know that it isn't Shift. It sounds like they have CMD mapped to Super (or at least that is the intention). – phils Jan 23 '19 at 21:45
  • I think the solution is that they missed the angle brackets. (kbd "<s-right>") is surely what they wanted. – phils Jan 23 '19 at 21:48
  • @g3mini, the crucial bit is that you plug the same description of the key sequence into kbd as Emacs gives you when you use C-h k or C-h c to inspect the key sequence. Emacs uses angle brackets in this instance, so that's also what you should be using with kbd. – phils Jan 23 '19 at 21:50
  • 1
    @Fólkvangr This is true, and there are various other ways of specifying key sequences too, however my best advice to anyone is to simply use the same exact description that Emacs gives you. Ask Emacs and use what it tells you, and you won't go wrong. – phils Jan 24 '19 at 19:00
  • What @phils said. Use the syntax that Emacs itself uses in *Help*, e.g. from C-h k. The Emacs manuals use a different syntax when talking about physical keys etc. There you will see syntax such as S-<right>. But it's best to go with what *Help* tells you. – Drew Jan 24 '19 at 22:55

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.