Stack Exchange Network

Stack Exchange network consists of 175 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

Questions tagged [key-bindings]

Keyboard shortcuts, key chords, key sequences, hotkeys, or any association between key combinations and corresponding actions in Emacs.

28
votes
3answers
5k views

Problems with keybindings when using terminal

I have the following line in init.el: (global-set-key [(control \;)] 'comment-region) It works very well in GUI window, but if emacs is invoked with the -nw option then C-; doesn't comment region, ...
35
votes
4answers
7k views

How to override major mode bindings

Sometimes my global keybindings are overridden by a major mode. An easy example is the following setting in my init file (global-set-key (kbd "C-j") 'newline-and-indent) But annoyingly this ...
59
votes
4answers
6k views

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

I have rebound a the 'd' key in gnus-article-mode, but its old behavior is still active when the point is on an attachment. I can see that the rebinding did not take effect there by doing C-h k d, but ...
4
votes
2answers
2k views

Defining key-bindings within `helm-map`: getting a `void-variable helm-map` error

Am going through this Helm tutorial at the moment; I pasted in the code verbatim (for now, I'll adapt it to suit my preferences later). I did a quick google search for this particular error but it ...
16
votes
2answers
4k views

Shift+Up isn't recognized by Emacs in a terminal

Very often I use Shift+Up/Down to select a region in Emacs. It works fine in GUI mode, but when emacs is invoked with -nw option I can select lines only with Shift+Down. The Shift+Up doesn't work, I ...
4
votes
2answers
301 views

Bind `C-x 8 l` to typing lambda (λ)

When I try to do this: (global-set-key (kbd "C-x 8 l") (lambda () (insert "λ"))) It just doesn't work: Wrong type argument: commandp (lambda nil (insert "λ")) Does anyone know a decent way to do ...
5
votes
3answers
2k views

Emacs bind key to prefix

suppose I want to bind a key to a partial key sequence (i.e. a key sequence that is a prefix of some other bound keybindings). I've tried the obvious (global-set-key (kbd "C-x C-x") (kbd "C-c")) ...
7
votes
5answers
707 views

Avoiding overwriting global key bindings

Okay, this is a persistent problem for me. As I continue to use emacs more and more, I'm starting to customize it to my needs by installing the packages(and/or defining functions) and the one big ...
14
votes
1answer
1k views

What is the difference between TAB and <tab>?

I was reading the the documentation for Yasnippet mode, when I came to the section where the trigger key is defined: It seems like Yasnippet minor mode defines the TAB key to run yas-expand using: (...
7
votes
3answers
2k views

How to remove bindings to the ESC prefix key

I'd like to use the ESC key instead of C-g for keyboard-quit. My naïve approach to just do (define-key global-map (kbd "ESC") 'keyboard-quit) does not work. ESC is still a prefix key and pressing it ...
19
votes
1answer
2k views

How to distinguish C-i from TAB?

Normally, for historic reasons, emacs treats the TAB keycode and the C-i key as the same, cf. the emacs lisp documentation on function keys or abo-abo's answer on the question "What is the difference ...
19
votes
7answers
1k views

Dired “quick-view” key to preview the file at point

I would like to create a function that does a "quick view" of a file the is under point in dired. The way that I would like for this to work is that I hold down a function key, which then makes the ...
13
votes
4answers
406 views

Differences between setting major mode keys with a hook versus adding them to the mode map

Assume that I have downloaded a major mode called magical-mode, and it has its own magical keymap called magical-mode-map. This mode also provides a hook magical-mode-hook which is run each time ...
7
votes
1answer
662 views

Simulating mouse operations with keyboard

Is there a way, via some command that can be invoked by the keyboard, of making Emacs think that I clicked at a particular point (so that it does whatever it would have done if I clicked there, e.g. ...
10
votes
2answers
2k views

Key bindings specific to a buffer

Is it possible to set key bindings specific to buffer? I have the following in one of my org files: # Local Variables: # eval: (local-set-key (kbd "<f10>") 'some-custom-defun-specific-to-this-...
12
votes
1answer
494 views

changing the role of the underline and the minus-sign just in LateX-mode

During the work with tex files with auctex+emacs (LateX-mode), I use more frequently _ (underline) instead of - (minus sign). The same as ^ instead of 6. The inconvenience is that I should press more ...
11
votes
1answer
766 views

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

Is there any way to bind C-[ to something and not have all M- (Meta) bindings messed up? Not the first time this question comes up. Unfortunately, the only solution offered in the previous thread is ...
3
votes
1answer
706 views

Why doesn't “C-;” “C-,”, or “C-.” work in a terminal emulator? (OS X Terminal, Iterm2) [duplicate]

I have bound "C-;" to 'other-window in my config like so. (global-set-key (kbd "C-;") 'other-window) When I run emacs outside of a terminal, this keybinding works as I would expect. Inside Iterm2 ...
10
votes
2answers
148 views

Is there a standard/recommended syntax for defining a keyboard binding?

I have seen all of the following for defining a keyboard binding. All of these work (at least on MS Windows). I don't know if there is another way to do the same thing. I am wondering if there is a ...
58
votes
17answers
28k views

How do I switch buffers quickly?

In vanilla Emacs, I have to do C-x b and then manually type out the buffer name to switch. If I forget the name of the buffer, I have to hit TAB to list possible completions. Is there anything I can ...
26
votes
6answers
10k views

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

I am trying out a new major mode, how can I take advantage of Emacs' documentation system to get a listing of key bindings available in that specific buffer?
7
votes
1answer
5k views

How to use a Mac's Command key as a Control key?

I'm new to Emacs, and am using a Mac. I want the Mac command key to act as a control key for Emacs. How do I do that? I tried (setq mac-command-modifier 'control). Besides, how do I find key ...
10
votes
1answer
3k views

How do I set up key bindings for modes in a specific Evil state?

I have a set of key bindings that I use for both web-mode and php-mode in insert mode (of Evil). So I cannot use set-local-map or something. Because in normal mode, the same keys will then call other ...
4
votes
3answers
915 views

How to type Org Mode's `M-` bindings in Emacs for Mac?

I'm having a hell of a time with getting Org Mode's key bindings to work. I thought that maybe the difficulties I was having had to do with what this page describes, since I was using Emacs text-mode ...
3
votes
2answers
2k views

Re-creating .vimrc key mappings in Emacs

I've been using vim for a while (though I'm only a basic user) and I've been trying out Emacs (specifically spacemacs). I have remapped H and L to go to the start / end of the line by adding the ...
3
votes
1answer
109 views

How can I 'layer' a keybinding?

I'm trying to create an emmet-like minor mode that will trigger on SPC (or TAB) if the previous text is expandable, but I don't want to completely override bindings that already exist for the key. ...
3
votes
1answer
1k views

How to remap : to ; in Evil Mode

What's the Evil Mode equivalent of these Vim commands? nnoremap : ; nnoremap ; : vnoremap : ; vnoremap ; :
3
votes
1answer
155 views

Bind function to the prefix key of Workgroups2 [duplicate]

I'm trying to make Workgroups2 more convenient by displaying a list of workgroups in the mini-buffer on pressing the prefix key (C-c z), e.g.: This makes it convenient to use the index 0-9 to switch ...
9
votes
4answers
420 views

Which keyboard shortcut to use for navigating out of a string

When I'm in the middle of a looooong string, like the following (setq Emacs-beta "Which keyboard shortcut to use for navigating out of a string") Can I skip out of it, just before the first " (after ...
8
votes
1answer
125 views

Set the home key to act as super?

I have a kinesis keyboard and would like to have the home key act as super in emacs without requiring me to remap my keyboard as well as edit my key bindings. Is there a simple way of doing this?
7
votes
1answer
347 views

How to bind C-[ for real?

C-[ is equivalent to the escape key on US English keyboards, thus, any attempt at binding it will mess up M- behaviour. Emacs seems to have no trouble telling <escape> and C-[ apart in GUI ...
7
votes
1answer
821 views

Helm: override C-h

I followed this answer and created my minor mode to avoid my keybindings being overridden by any major modes. So I put this in my init.el: (define-key my-keys-mode-map (kbd "C-h") 'delete-backward-...
7
votes
4answers
748 views

The C-x C-j binding for dired-jump stopped working

I used to have a keyboard shortcut for the following action: "Open the folder containing this file in Dired+, and place point (cursor) on the file" I believe it was C-x C-j, and I don't recall ...
6
votes
3answers
4k views

How to unbind a key?

I want to get rid of the C-e binding so I can bind C-e e, and C-e r to a command. How do I do this? My .emacs is (global-set-key (kbd "C-e e) 'move-end-of-line) (global-set-key (kbd "C-e r) 'end-of-...
3
votes
1answer
99 views

How to use one binding to call different functions depending on whether the region is active?

As I only use kill-ring-save after I used set-mark-command, I wanted to try using its binding also for another command. However I'm not able to get this to work with an additional if. I don't know how ...
2
votes
1answer
496 views

How to set copy to C-c in Emacs?

I have tried using Cua mode (via adding (cua-mode t) to my ~/.emacs file) but it doesn't seem to set the copy keybinding to Ctrl-c. See for example this screenshot showing my Edit menu: I have tried ...
2
votes
1answer
382 views

Remove key binding in magit-status-mode

I have C-RET set to other-window globally. For modes that would override this I manually add a hook to the mode's key map, e.g. (add-hook 'magit-log-mode-hook (lambda () (local-unset-key (kbd "<C-...
25
votes
4answers
4k views

How can I simulate an arbitary key event from Elisp?

Is it possible to simulate an arbitrary key event from elisp? I am aware of ways that I can find the binding for a given key, and then call that command interactively, but what if that key event is ...
20
votes
2answers
346 views

Is there a function to insert the correct `(kbd “…”)` by pressing the key?

I'm bored of looking up key names for the kbd function, is there a way to automatically insert the correct key name just by pressing the key? So for example I want something to do this: I'm typing (...
14
votes
1answer
2k views

How to distinguish C-m from RETURN?

When in javascript mode trying to use C-c C-m i get an error saying "C-c RET is undefined?" What makes Emacs believe I am pressing RET? How can i properly make this keybinding work?
10
votes
1answer
3k views

How to remap Company's select next and select previous keys?

I don't like the default M-n and M-p keys for company-select-next and company-select-previous so I was wondering if it's possible to remap those to C-n and C-p without affecting the mappings when ...
14
votes
4answers
2k views

Use Super in emacs -nw in linux

I have been struggling to find a simple and direct question to the answer and therefore I have decided to ask here. Q: Is there a way to use Super in Emacs launched in a Terminal in Linux? P.S: I ...
10
votes
3answers
3k views

How can I stop the enter key from triggering a completion in company mode?

I often want to go to a newline while the company mode suggestion is showing. How can I set up company mode so only the tab key triggers a completion?
11
votes
3answers
369 views

What is the select word/symbol function bound to <double-mouse-1>

I love the ability to select word/symbol at point which I currently do with double mouse click. I would like to be able to do it from the keyboard, and so I'd like to bind it to a keystroke (or maybe ...
4
votes
1answer
686 views

How bind keys to a specific snippet in yasnippet folder?

Let's say I have a yasnippet snippet called foobar and I have configured it to work it with company-mode (which is not relevant here). Now each time I needed to type foobar I would select it from ...
9
votes
1answer
761 views

How to get keystrokes displayed in the echo area immediately?

How do I get keystrokes displayed in the echo area immediately? For example: when I enter the key sequence C-u j, it will not display in the echo area immediately, but then I press key k, and I ...
6
votes
3answers
422 views

Non-symmetric keychord

I currently have this in my init file (key-chord-define-global "xf" 'find-file). Actually, xf and fx will trigger the find-file function. In fact, whatever the keychord I defined, it works whatever ...
6
votes
1answer
757 views

How to extend the <ESC> => M- translation to non-character keys?

This question is a follow-up to this answer (q.v.). I understand that Emacs interprets esc as M- only when the keystroke that follows it corresponds to a "character" (e.g. A, 5, ;, etc.), as opposed ...
5
votes
1answer
217 views

Why does C-c C-x look like an empty keymap?

I'm trying to find which map C-c C-x is bound to on my system, but C-c C-x C-h reveals nothing. (describe-key (kbd "C-c C-x")) reports that the sequence is unbound, yet I can still type C-c C-x and ...
10
votes
4answers
1k views

Problem “<dead-acute> is undefined” appearing when typing Greek stress ( ' )

I started using Emacs and I wrote a text in Greek. The problem is that the stress that is used upon some letters (ό, ύ, ί, ύ) doesn't work! It is usually inserted by pressing the ; (I mean by ...