What are good custom keybindings in emacs?

后端 未结 5 555
醉梦人生
醉梦人生 2021-02-05 15:35

Emacs seems to have all the possible keyboard combinations already randomly distributed among it\'s commands. :p

If I am to define new keyboard shortcuts, where should I

5条回答
  •  青春惊慌失措
    2021-02-05 16:12

    Emacs actually has a very definite pattern to its bindings, this answer shows some.

    As far as where you should define keys, if you take a look at the documentation for conventions, you'll see that C-c a (where a is any lower or upper case character) is reserved for users.

    Plus, if you're defining a key that really only makes sense in a particular mode, then you should define it in that keymap.

    For example, M-/ is bound to dabbrev-expand, which is a handy way of autocompleting the word you're typing. It might very well make sense to use rsense-complete instead, but only when you're in ruby. In which case, you can do this:

    (add-hook 'ruby-mode-hook
         (lambda () (define-key ruby-mode-map (kbd "M-/") 'rsense-complete)))
    

    That will override the binding for M-/ only when you're in ruby-mode, and leave it unchanged (or available) for the rest of the modes.

提交回复
热议问题