Skip to main content

Questions tagged [key-bindings]

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

Filter by
Sorted by
Tagged with
41 votes
6 answers
18k 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, ...
WeSenseASoulInSearchOfAnswers's user avatar
56 votes
6 answers
15k 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 ...
nispio's user avatar
  • 8,245
72 votes
5 answers
19k 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 ...
brab's user avatar
  • 925
20 votes
2 answers
3k views

How to bind C-i as different from TAB?

I want to make Control-i perform indent-region (basically since Xcode has built that muscle memory already). I realise that Control-i and tab are indistinguishable in the Ascii sense, but they are in ...
Mark's user avatar
  • 1,449
15 votes
3 answers
7k 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 ...
WeSenseASoulInSearchOfAnswers's user avatar
5 votes
2 answers
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 ...
iceman's user avatar
  • 1,088
20 votes
1 answer
6k 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: (...
Håkon Hægland's user avatar
11 votes
5 answers
3k 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 ...
Chakravarthy Raghunandan's user avatar
10 votes
3 answers
5k 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")) ...
PythonNut's user avatar
  • 10.4k
16 votes
4 answers
5k 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 ...
Geier's user avatar
  • 742
5 votes
2 answers
630 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 ...
Czipperz's user avatar
  • 317
1 vote
2 answers
582 views

How can I override an OS key binding in Emacs?

One of my major modes defines the key binding C-M-t, but every time I use it, my operating system (Ubuntu Linux) intercepts the key binding and opens a terminal. The OS key binding overrides the Emacs ...
Pedro Delfino's user avatar
26 votes
3 answers
19k 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 init file has this: (global-set-key (kbd "C-e e") 'move-end-of-line) (global-...
Joshua Lilleberg's user avatar
31 votes
1 answer
4k 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 ...
elemakil's user avatar
  • 2,537
68 votes
8 answers
36k 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?
nixeagle's user avatar
  • 2,457
19 votes
7 answers
5k 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 ...
Eric Brown's user avatar
  • 3,232
17 votes
2 answers
4k 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-...
Kaushal Modi's user avatar
  • 25.7k
15 votes
2 answers
2k 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 ...
Kristóf Marussy's user avatar
15 votes
4 answers
816 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 ...
nispio's user avatar
  • 8,245
11 votes
1 answer
1k 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 ...
zeRusski's user avatar
  • 335
11 votes
1 answer
766 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 ...
Name's user avatar
  • 7,895
10 votes
2 answers
195 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 ...
Name's user avatar
  • 7,895
10 votes
1 answer
1k 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. ...
ShreevatsaR's user avatar
4 votes
2 answers
291 views

How do I add a keybinding to use during an interactive isearch, `C-s ...`

Can I assign a key binding starting with C-s such as: (global-set-key (kbd "C-s C-w") 'isearch-forward-symbol-at-point) but I want to keep (kbd "C-s") for i-search. I am having following error: ...
alper's user avatar
  • 1,400
4 votes
1 answer
2k 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 ...
Greg Nisbet's user avatar
3 votes
1 answer
1k views

Priority of keymapping commands

In another question (IDO rebind C-j to C-<RET>), Seraph asked about defining the <C-return> key for ido-mode. It turned out that the key was already bound in cua-global-keymap, which ...
Realraptor's user avatar
  • 1,293
3 votes
1 answer
222 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. ...
Sean Allred's user avatar
  • 6,951
1 vote
5 answers
2k views

How to swap `super` and `meta` in terminal Emacs in Kitty on macOS?

For example, when I press command + d, I want to run the default M-d command kill-word. But instead it runs S-d. How can I do that in terminal Emacs in Kitty terminal on macOS (I don't want to ...
Saddle Point's user avatar
0 votes
3 answers
546 views

Why can't I type things such as "?" and "/" in Emacs with my macOS running Brazilian Portuguese input but they do work outside of Emacs?

I have been using Emacs on a NixOS (Linux) machine running GNOME as a Desktop Environment. The hardware interface of this system is an American keyboard. Since I am Brazilian, it was necessary for me ...
Pedro Delfino's user avatar
90 votes
25 answers
60k 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 ...
nixeagle's user avatar
  • 2,457
18 votes
1 answer
16k 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 ...
LoranceChen's user avatar
15 votes
2 answers
4k 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?
user3139545's user avatar
12 votes
2 answers
8k views

How to remap backward-delete and help command while using Emacs from a terminal emulator?

I was using Emacs on CentOS 7 from the MobaXterm terminal on Windows 7, but the backspace key instead of backward-deleting a character invokes the prefix command C-h. According to EmacsWiki, I tried ...
Joseph Tesfaye's user avatar
12 votes
1 answer
4k 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 ...
caisah's user avatar
  • 4,096
11 votes
1 answer
5k 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 ...
ReneFroger's user avatar
  • 3,890
11 votes
1 answer
585 views

Difference between [mouse-1] and [down-mouse-1]

I noticed two keys: [mouse-1] and [down-mouse-1]. When I use describe-key with a single click, it shows: There were several key-sequences: <down-mouse-1> at that spot runs the command evil-...
FunkyBaby's user avatar
  • 807
9 votes
4 answers
595 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 ...
Dieter.Wilhelm's user avatar
9 votes
1 answer
471 views

How to describe a key sequence that starts with `C-u`?

I am trying to use C-h k to describe the function to which a key is bound. But when I use it with a key chord like C-u C-e C-x it retrieves the documentation for C-u before I can finish typing the ...
lookyhooky's user avatar
8 votes
1 answer
1k 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-...
Boccaperta-IT's user avatar
8 votes
1 answer
9k views

Wrong number of arguments on lambda key binding

I am not able to figure out what is wrong in this elisp form: (define-key ggtags-mode-map (kbd "M-.") (lambda () (interactive) (ggtags-find-tag-dwim) (recenter))) I keep getting this ...
SFbay007's user avatar
  • 584
7 votes
1 answer
436 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?
dst's user avatar
  • 71
7 votes
5 answers
1k 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 ...
Amelio Vazquez-Reina's user avatar
6 votes
1 answer
1k views

How to remap control up in org-mode

Newer versions of org-mode remap C-up to org-backward-paragraph. I would like C-up not to be remapped (and continue to use the standard Emacs' backward-paragraph instead). But the standard ways of ...
scaramouche's user avatar
  • 1,754
6 votes
1 answer
5k views

How to make <tab> work in org mode when combined with evil mode?

In evil mode, I would like C-i not to work as a tab key, which is the default behavior in Emacs. Also, I would not have the default vi behavior simulated in Emacs evil by evil-jump-forward, but ...
Håkon Hægland's user avatar
5 votes
1 answer
6k views

How to remap : to ; in Evil Mode

What's the Evil Mode equivalent of these Vim commands? nnoremap : ; nnoremap ; : vnoremap : ; vnoremap ; :
Jay's user avatar
  • 181
4 votes
1 answer
2k views

Unbind key in org-mode (with evil-mode)

I cannot unbind the key M-l in org-mode. When the cursor is in an org-mode buffer, I tried to eval (M-:) (unbind-key "M-l" org-mode-map) ;; ^^^ from bind-key.el (define-key org-mode-map (kbd "M-l") ...
schoettl's user avatar
  • 143
4 votes
1 answer
381 views

C-; shows a strange popup with letter 'e'

I don't know when this problem began, may be 1 or 2 months ago. When I press "C-;", Emacs shows a popup with letter "e". But this key binding is for "avy-goto-char-timer"...
M-x C-g's user avatar
  • 41
4 votes
3 answers
2k 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 ...
kjo's user avatar
  • 3,257
3 votes
2 answers
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 ...
baxx's user avatar
  • 137
3 votes
1 answer
765 views

Moving from legacy function global-set-key to keymap-global-set

The documentation in the release of GNU Emacs 29.0.50 states that global-set-key is a legacy function; instructing people that the recommended function to use is keymap-global-set. What would be the ...
Dilna's user avatar
  • 1