Hot answers tagged

68 votes
Accepted

How can I find out in which keymap a key is bound?

Emacs 25 As mentioned by @YoungFrog in the comments, starting with Emacs 25.1, the good-old C-h k method of describing key-binds will also tell you which keymap the key was found in. Before Emacs 25 ...
user avatar
  • 22.4k
66 votes

How do I list all key-bindings available in a given buffer?

C-h b will list all the bindings available in a buffer. This is a mnemonic for help (C-h) bindings (b). You can also get a list of keybindings via C-h m, which is help for the major and minor modes ...
user avatar
  • 20.4k
49 votes
Accepted

How to override major mode bindings

There is a "shortcut" approach too for the same solution if you don't want to define your own minor mode (that I talk about in my first answer). You can install the use-package package available from ...
user avatar
  • 24.3k
36 votes

How to override major mode bindings

You can define your own minor mode and its key map and have that override all other modes (minor + major). That's exactly why I chose to write my own minor mode. Steps to have your key bindings ...
user avatar
  • 24.3k
28 votes

How do I list all key-bindings available in a given buffer?

I use the command helm-descbinds, which is available via melpa. I mapped it to C-h b because it is basically a drop-in replacement for describe-bindings. The benefit is that it is easier to navigate ...
user avatar
  • 7,833
24 votes

How to distinguish C-i from TAB?

The future is long gone, and the stone age of computing is just about to come. All text terminals I know still send the exact same byte-sequence to Emacs for C-i as for TAB, so the original need to "...
user avatar
  • 25.4k
23 votes
Accepted

What is the longest known key sequence in Emacs?

I tested with the following script, (key-description (car (sort (let (keyseqs) (mapatoms (lambda (sym) (when (commandp sym) (let ((where (where-is-internal sym nil ...
user avatar
  • 1,260
21 votes
Accepted

How to bind your keys to keymaps that aren't loaded yet?

You can use with-eval-after-load to defer the key binding until after a certain module has been loaded (and thus defined the keymap): (with-eval-after-load "helm" (bind-key "M-Y" #'helm-end-of-...
user avatar
  • 5,854
21 votes
Accepted

Differences between evil-normal-state-map and evil-motion-state-map

Motion state is an Evil-specific thing, intended for modes where you don't edit text, but still want Vim-style movement available, with all other keys of that mode passing through. Help buffers are ...
user avatar
  • 21.1k
20 votes
Accepted

How to bind C-i as different from TAB?

I don't think that this can be achieved from a terminal, but in GUI mode you could try this: (define-key input-decode-map [?\C-i] [C-i]) (global-set-key (kbd "<C-i>") 'indent-region) I do the ...
user avatar
  • 7,833
18 votes
Accepted

Key bindings specific to a buffer

For closure, here is an answer that expands upon my comment. I define a minor mode with the required keybinding and toggle it in the required buffer using file local variables. (define-minor-mode ...
user avatar
  • 3,826
17 votes

How to bind C-i as different from TAB?

GUI frames In GUI frames (whether X11, Windows, OSX, …), Emacs reads the Tab key as the tab function key. However, because the Tab key on terminals traditionally sends the ^I (Control+I) character, ...
user avatar
16 votes
Accepted

How to truly unbind ALL global keybinds?

Taken from the Emacs Lisp Manual (see Controlling Active Maps): (use-global-map (make-sparse-keymap)) To quote the manual: "It is very unusual to change the global keymap.". Safety note: Make sure ...
user avatar
  • 21.1k
15 votes
Accepted

How can I look up help for a key sequence that I can't type

Evaluate the following using eval-expression (M-:) or in a scratch buffer: (describe-key (kbd "C-<whatever>"))
user avatar
  • 4,968
15 votes
Accepted

How to bind a key to a specific agenda command/list in org mode

You can do this by wrapping a call to org-agenda into a custom command and binding that to a key: (defun org-agenda-show-unscheduled (&optional arg) (interactive "P") (org-agenda arg "u")) (...
user avatar
  • 14.2k
15 votes
Accepted

How can I go from a key 'code' back to its keyboard equivalency?

help-key-description is used to display a humanly-readable key in the documentation when you invoke describe-key (C-hk). (help-key-description [22] nil) ;; --> "C-v" (help-key-description [...
user avatar
14 votes
Accepted

How to find out what a key sequence really does

There is no easy way to know exactly what a single key press will do. If you see additional behavior always check the common hooks. See the list here: http://www.gnu.org/software/emacs/manual/...
user avatar
13 votes
Accepted

org-mode sans arrow keys

Without remapping, you can already get by pretty well without arrow keys. C-c C-x C-h in an Org buffer: C-c C-x D org-shiftmetadown C-c C-x L org-shiftmetaleft C-c C-x R org-...
user avatar
  • 6,464
12 votes
Accepted

Use two major-mode-maps in the same buffer

This turned out to be simpler then expected. As suggested in the comments here and on the question: (with-eval-after-load 'erc (require 'markdown-mode) (require 'cl-lib) (setq erc-mode-map ...
user avatar
  • 22.4k
10 votes
Accepted

Evil: map keybindings the vim way?

I've got it working now, thanks to your answers: (defun my-jump-to-tag () (interactive) (evil-emacs-state) (call-interactively (key-binding (kbd "M-."))) (evil-change-to-previous-state (other-...
user avatar
  • 356
10 votes

How do I list all key-bindings available in a given buffer?

Although not the canonical emacs way of doing things, I quite like using discover-my-major for that purpose because it just feels more effective. It is available on melpa and is powered by the makey ...
user avatar
  • 2,447
9 votes

How can I look up help for a key sequence that I can't type

If you can't use a particular key combination because of your terminal, you can often fake it by manually simulating the key modifier. The following combinations work exactly as though you had used ...
user avatar
  • 1,316
9 votes

Dired "quick-view" key to preview the file at point

Here is my super hacky way to simulate key down/up event binding by taking advantage of timers. Overall I would suggest going by Sigma's answer, but you asked for a way to close the preview by ...
user avatar
9 votes

Key translation

The input translation maps (input-decode-map, local-function-key-map, function-key-map, key-translation-map) apply only within a key sequence. While you can specify multiple keys in the output of the ...
user avatar
9 votes

How to truly unbind ALL global keybinds?

Although the following information is not a direct answer to the question (since it was already answered by @wasamasa), I still believe that it is an essential addition to the answer. The point is ...
user avatar
9 votes
Accepted

Is possible to execute a key binding in a function?

You can use funcall and key-binding to do this: (funcall (key-binding (kbd "C-M-j"))) will execute the function currently bound to C-M-j. funcall lets you pass in arguments as well, if needed. ...
user avatar
  • 2,270
9 votes
Accepted

How to bind C-[ for real (seriously for real this time)

Adapted from my own config: (define-key input-decode-map [?\C-\[] (kbd "<C-[>")) (global-set-key (kbd "<C-[>") 'butterfly) This will obviously only work in the GUI. edit: Note that ...
user avatar
  • 21.1k
9 votes

How to bind your keys to keymaps that aren't loaded yet?

Solution In order to execute stuff after a given package is loaded, you need to put that after :config in use-package. Here's an example using the snippet in your question: Snippet # 1 (use-...
user avatar
  • 24.3k
9 votes
Accepted

How to find out which function is bound to C-u C-SPC?

Leave the C-u off and check the binding for C-SPC (or whatever you're interested in). The universal argument (the C-u) is often used to make commands do different things. However, the docstring of ...
user avatar
  • 31.1k

Only top scored, non community-wiki answers of a minimum length are eligible