Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Keyboard shortcut completion help in emacs?

Tags:

emacs

I was wondering if there is anything in emacs which will help me remember keyboard shortcuts?

For example, if I press C-x and then press some key (say TAB), emacs should all possible combinations of C-X and other keys to give an emacs command (and also show what the command does)?

like image 405
n1kh1lp Avatar asked Jan 14 '10 12:01

n1kh1lp


People also ask

How do I set keyboard shortcuts in Emacs?

Keys can be bound to commands either interactively or in your . emacs file. To interactively bind keys for all modes, type M-x global-set-key RET key cmd RET . To bind a key just in the current major mode, type M-x local-set-key RET key cmd RET .

What does Ctrl C do in Emacs?

Binding Ctrl+c and Ctrl+x to both copy and cut and emacs keys.

What is the M key in Emacs?

Summary of essential emacs commands In the list below, C- means "control key", M- means "meta key" (escape).


5 Answers

There is a simpler way to do this than C-h m. You can see all the combinations you need by pressing C-h. Let me explain with an example. Say you want to run the command org-narrow-to-subtree, which in my case is bound to C-x n s I remember that I have to type C-x n but don't remember the next part. I can type C-x n C-h and emacs will show me the following:

Global Bindings Starting With C-x n:
key             binding
---             -------

C-x n d     narrow-to-defun
C-x n n     narrow-to-region
C-x n p     narrow-to-page
C-x n r     narrow-to-region
C-x n s     org-narrow-to-subtree
C-x n w     widen

[back]

So in your case, to see all possibilities after C-x, just type C-x C-h

like image 156
vedang Avatar answered Sep 17 '22 00:09

vedang


You can use C-h m to list and describe all active keybindings in current buffer (depending on your active major and minor modes).

like image 39
juba Avatar answered Sep 17 '22 00:09

juba


Not a complete answer but partial:

  • The Emacs user manual has a key index which lists all the key sequences (Emacs' preferred term for what you call keyboard shortcuts).
  • C-x C-h opens a buffer listing key sequences beginning C-x.
  • C-h k followed by a key sequence describes the key sequence.
  • C-h K followed by a key sequence takes you to the right page of the user manual.
like image 31
High Performance Mark Avatar answered Sep 18 '22 00:09

High Performance Mark


I think one-key is what's your looking for One key

like image 39
driftcrow Avatar answered Sep 21 '22 00:09

driftcrow


In Icicles you have key completion, which is just about what you described.

You know the help that is offered when you hit a prefix key and then C-h -- e.g. C-x C-h? Well that's just help, and it works only for certain prefixes.

What this Icicles feature is about is actually completing key sequences: hit C-x, then S-TAB to complete, and every possible completion of prefix key C-x is displayed -- just pick one.

If the candidate you picked is itself a prefix key (e.g. you picked r, so so far you're up to C-x r, which is still incomplete), then you pick another piece of the sequence, and so on, until the key sequence is complete (and its command is invoked).

See also:

like image 29
Drew Avatar answered Sep 19 '22 00:09

Drew