I want to make a prefix key. So which command is better for making a prefix key?


  • 2
    Newcomers to Emacs keybindings are well advised to read this excellent article: masteringemacs.org/article/mastering-key-bindings-emacs (it's way more information than you're asking for, but it will answer a ton of questions that you haven't asked yet).
    – phils
    Commented Jul 26, 2017 at 10:06
  • @phils Thx for your advice :)
    – Big Shield
    Commented Jul 27, 2017 at 1:50
  • @Drew Edited. That means making a prefix key.
    – Big Shield
    Commented Jul 27, 2017 at 1:53

1 Answer 1


The short answer:

If you wish the prefix to be present in all buffers and all modes, use global-set-key. If you wish it to be present only in one mode, use local-set-key.

The difference between the two is what keymap they put the binding into: The global one, or the local one. When you type a key sequence, the local map is searched first, then the global one. So a binding in the local map could shadow the global binding. Each major mode typically defines its own local map, which is shared among all buffers using that mode.

There is much more to say about keymaps and keymap searching, but this should be a good start.

  • Do you mean that the choice is based on modes or a mode?
    – Big Shield
    Commented Jul 26, 2017 at 9:27
  • If you mean your choice of which one to use, it depends how you are going to use it. Commented Jul 26, 2017 at 10:03

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.