reddit / emacs

What's a good way to learn the available keybindings?

SteveTheGreate · 2022-01-26 08:44
I've been using Doom Emacs for a few months now, and I keep finding all the amazing features it has to offer. The problem is that there are so many features that I'm afraid of missing out on some of the most useful ones simply due to the sheer amount of commands available. For example, I had no idea that you could move text up or down a line by holding down alt and then the up or down arrow keys, or that you could navigate through paragraphs with the curly brackets. These are all incredible features that could save me hours of time.
rfeynman42 · 2022-01-26 09:01
[which-key](https://github.com/justbur/emacs-which-key) is a nice way to stumble upon some new key bindings and is especially useful when similar things share the same leading sequence of keys (and it's been a while since I used doom but that should be the case for it)
BobKoss · 2022-01-26 09:19
I watch youtube videos and make a cheat-sheet for anything I find interesting. I use a sticky-note so it's right in front of me. After a few times, it becomes muscle memory.
briang_ · 2022-01-26 09:56
I wouldn't recommend this method, but you can dump all keybindings in vanilla emacs with `M-x describe-bindings RET` (bound to `C-h b`). I presume you can do the same in Doom. All you have to do is Learn Them All :)
[deleted] · 2022-01-26 10:05
[deleted]
Awllower · 2022-01-26 10:48
OP is already using Doom Emacs. Why recommend Doom when OP is already using it?
SteveTheGreate · 2022-01-26 11:13
As the other comentator said, I'm already using Doom Emacs. If I had to set up emacs from scratch I honestly don't think I would make it a week without giving up.
ElCondorHerido · 2022-01-26 11:41
Honestly, reading the manual(s)
demonfell · 2022-01-26 11:42
I originally learned Emacs key bindings in order to use them in bash, which then led me to try to adopt Emacs. I made a text document with the equivalent vi -> Emacs keystrokes for my most commonly used operations. The on board tutorial for vanilla Emacs will get you started with using and learning the native Emacs keybindings.
J-ky · 2022-01-26 11:54
C-h k
andreyorst · 2022-01-26 12:05
C-h m
centzon400 · 2022-01-26 13:15
> I originally learned Emacs key bindings in order to use them in bash, which then led me to try to adopt Emacs Not just BASH. `man readline` It's glorious.
demonfell · 2022-01-26 13:44
For sure, has been useful in many different contexts.
paretoOptimalDev · 2022-01-26 13:47
I use which-key, but I've found the number of bindings it shows and/or how it shows them overwhelming for some reason.
patrick_thomson · 2022-01-26 14:04
Don’t know why you were downvoted—this is a great piece of advice, even for those of us who hate watching videos. When learning a new major mode (for me right now it’s AuCTeX) I keep a notepad by me for notes.
sunnyata · 2022-01-26 14:08
Then turn back now! /jk
cazzipropri · 2022-01-26 14:24
The best way to learn the keybindings is to ***make your own.*** A lot of Emacs's inherited keybindings are frankly so outdated in 2022 as to be nonsensical. You can unbind them and reclaim those combinations to something more useful to you.
plantarum · 2022-01-26 14:52
I haven't had much success studying large groups of keybindings. It's too much for my brain to assimilate. What has worked for me is to identify a particular keybinding, and to deliberately practice it, a few minutes at a time, over the course of a few days. For example, when I wanted to be more efficient in moving point around the screen, so I started using \`avy-goto-char-timer\`. I bound it (or maybe this was the default?) it to \`C-;\`. Then I played around for a few minutes, pressing \`C-;\` and jumping around the screen, just to get warmed up. Then the next time I noticed I was moving the point manually (\`C-n/p/f/b\`) to get somewhere, I'd move point back to where I started, and make myself use \`C-;\`. And I'd repeat this a few times over, maybe spend a minute or two. Repeat this over the course of a few days, with some deliberate practice sessions (just a minute or two) thrown in. After a few days, the keybinding is fixed in my head, and I don't need to think about it anymore. People often complain that Emacs is too big and complex to learn. It's definitely big and complex. But I find it manageable to deal with learning one or two new things at a time, and focusing on features that I will use frequently so that they quickly become second nature. I don't bother trying to memorize complex key chains for things I don't use every day. Orgmode has a ton of these. I just use the menu or M-x function-name for that stuff.
Sethaman · 2022-01-26 15:02
which-key... followed by setting up some of your own bindings.
metacontent · 2022-01-26 15:30
Same here, but I use a whiteboard on the wall beside my desk.
lets-start-reading · 2022-01-26 15:35
1. take a key-command reference card. easier to take ready-made. go to \*scratch\* and try them all out. e.g. [GNU key-command ref card](https://www.gnu.org/software/emacs/refcards/pdf/refcard.pdf) 2. have a file to yank key-commands you feel are useful. (I've created org files for different areas, such as file-management, buffer-management, text-editing, etc. They all rest in an emacs directory, where I keep notes about how to handle things in emacs. it's one directory away from my home folder) 3. implement them. go about your day in emacs, but each time you do something, think if you haven't already saved a key-command that does this. first, try to remember it. if you can't go check your key-command file. 4. when you notice you're using some key-commands instinctively already, archive them. I notice \`C-h k\` doesn't help me much when learning – it requires me to know the key-command already. \`C-h r\` on the other hand, has a key index. \`C-s\` in it if you want to check if any key is bound to a command you want.
rileyphone · 2022-01-26 16:49
For a lot of things I search for what I'm trying to do after SPC - : / M-x, and the keybinding, if there is one, is shown there.
LeeRuns · 2022-01-26 17:23
i know this is silly but i just broke it all into small chunks. Each day I would write 1-3 of the key bindings down. Then I would use those throughout the day. Once I learned those 3 and was not thinking about it I made a new post it. This stuff does take time, and remember it's nice, but don't let it prevent you from being productive everywhere. Our minds like to learn things in small pieces over long periods of time. Keep trying :)
00-11 · 2022-01-26 17:35
`C-h b` just shows you the bindings that are available in the current context.
BobKoss · 2022-01-26 17:41
I’m a little confused. Isn’t which-key behavior exactly what Doom does when you press SPC?
slipperyp · 2022-01-26 17:41
* describe-key - tells you what function a key combination does * Describe-function - tells you what a function does * Where-is - tells you what keys a function is bound to * Apropos - searches for functions that do something * Describe-mode - tells you what a mouse does Those are the main ones, imo. Other than this, you need to learn the major and modes, but this can help navigate the most important things as you are learning.
00-11 · 2022-01-26 17:42
1. [Icicles](https://www.emacswiki.org/emacs/EmacsNewbieWithIcicles#PossibleKeyBindings) help. Learn first *how to recover* when you seem to have fallen down a black hole :`C-g`, `C-_`, `C-]`, `C-h l`, `M-x top-level`. Icicles [key completion](https://www.emacswiki.org/emacs/Icicles_-_Key_Completion): complete key sequences and menu-bar menus. Completion against *key* name, *command* name, or both. Sort candidates on the fly, by (1) *local keys* first, (2) *prefix keys* first, or (3) *command name* alphabetically. 2. [Key See](https://www.emacswiki.org/emacs/KeySee) key completion. (Subset of what Icicles offers.)
SlowValue · 2022-01-26 18:08
My favorite (and I believe superior) options are: I use the completion `ivy` together with `ivy-rich`. By using `M-x` this combo shows the shortcut behind every command (if the command has a shortcut defined). So you can narrow down the list and are not overwhelmed. I even wrote a command `M-X`, which only lists commands with shortcuts. (`vertico` with `marginalia` is a possible combo too, I think. I'm sure `helm` can do that too.). The next best option is to use Emacs's menu bar menus! The only problem here is, than quite some packages don't define good menus. So you would have to define menus yourself with `easy-menu`, when you are adapting a new package. (`isearch` is a prominent bad example here, but it is possible to define this menu yourself). Defining Menus yourself is also a good way to remember important commands.
BeetleB · 2022-01-26 18:20
For years my Emacs abilities were hampered because of this. The two things that helped immensely: 1. Spaced repetition (specifically I used org-drill). I can't understate how effective it is. 2. Learning to make [hydras](https://github.com/abo-abo/hydra). Now when I encounter an interesting mode, I don't memorize the keybindings - I just create my own hydra for it.
liuxicin · 2022-01-26 19:21
Almost same here, a help.org file in the default dir, where I write short cut I discover and use often. BTW, there will soon be a problem on how To structure this keys.
crundar · 2022-01-26 19:59
~ $ man readline No manual entry for readline ~ $
centzon400 · 2022-01-26 20:36
Really? No info either? There should be a section in the manual for bash re. readline too. Failing that: https://linux.die.net/man/3/readline
CulturMultur · 2022-01-26 23:01
`<prefix> C-h`: `C-c C-h`, `C-x C-h` and so on. which-key doesn't train to remember key bindings, so I stopped using it.
kittyfangz · 2022-01-26 23:17
pretty sure doom uses which-key
rfeynman42 · 2022-01-27 02:48
Oops! Yeah, it's clearly been a bit since I've used Doom. Nevertheless, part of the advice still stands — pay attention to `which-key` some more and you'll learn plenty of new keybinds.
Yekrats · 2022-01-27 04:29
Where would those be for Doom Emacs?
jeenajeena · 2022-01-27 07:10
I just use m-x and run commands by their names, for the first usages. They are shown with their keybinding, so when I eventually get bored of liking for them via their name, I switch to keybinding.
CoolioDood · 2022-01-27 10:07
So there's two parts to this: discovering, and learning. For discovering: I just use GNU Emacs so I'm not sure about Doom, but in GNU Emacs I can do `C-h b` to show bindings, and `C-h m` to describe the current modes (and with the packages Ivy and Counsel, I can search the lists). From there, I can find whatever is useful. The package which-key is also good for showing what keys are bound to functions. And of course, the manual is a good resource. For learning: I put the ones I can't "just" remember into [Anki](https://apps.ankiweb.net/), a FOSS flashcard system based on spaced repetition (for example, the front of a card would be "emacs org: how do you toggle a checkbox?", and the back would be "C-c C-x C-b"). I use [anki-editor-mode](https://github.com/louietan/anki-editor) to make this faster. Then I do an Anki review every day.
ElCondorHerido · 2022-01-27 11:51
I don't mean the Doom manuals. Read the emacs manuals and the manuals for critical packages in doom (org, evil, ivy). The show all the useful functions and config option. It this then a matter of finding the keybinding for those functions in doom
dpoggio · 2022-01-29 05:06
This is wrong. Emacs is absolutely self documented. You have C-h, describe-mode and a thousand other beautiful tools to discover eMacs from emacs. Even Helm includes ways of browsing the docs.
ElCondorHerido · 2022-01-29 12:14
Ok. Read the manual, from within emacs. Is that better?
dpoggio · 2022-01-29 16:37
The pieces of doc you get of C-c C-h, or C-h k or C-h m aren’t the same as the manuals.
esloks · 2022-02-01 16:16
Originally when I wanted to learn all the emacs keybindings I just put the cheat sheet as my background image. Worked really well. I think that I needed it for maybe a month maybe less.
esloks · 2022-02-01 16:25
I would slightly advise against this. I used to go this path and it was good for learning hotkeys, but at some point there starts to be an accumulating amount of conflicts. Many packages already have keybindings and a design principle that work in context of normalish emacs keybindings. The emacs layout is also kind of a standard available in multiple places. Currently I have the same base emacs hotkeys even while using my browser via xkeysnail. Works actually really well.
cazzipropri · 2022-02-01 18:11
You raise valid points, that I agree with. Maybe I got away so far with what I'm doing because I mostly * remap function keys (which most packages seem to ignore), * map exotic extra function keys (on keyboards that have more than 104 keys, e.g., the IBM M122 [https://www.reddit.com/r/modelm/comments/shwjwg/i\_refreshed\_my\_m122\_resources\_and\_keymaps/](https://www.reddit.com/r/modelm/comments/shwjwg/i_refreshed_my_m122_resources_and_keymaps/) ) which no existing package would use, and * I reclaim ancestral bindings (like C-f or C-b) whose origin is lost in time, which everybody probably consider untouchable, and that packages would also not dare change. Does it make a bit more sense now?
esloks · 2022-02-05 16:06
I personally really like having the C-n C-f and so on. For me one big thing about emacs was that I could move freely directly from the letter row on keyboard. There are popular packages such as org-mode for example that have default bindings that assume you are familiar with moving using c-n and so on. For example you jump to next same level entry by using C-c f and next entry by C-c n. Its not really absolutely necessary to use them but it is a part of the idea. Org has a lot of keys such as these and it is not the only example. M-g n makes you jump to next error in code and if you want to bind c-s to c-f you may need more conflict solving if you want some search extension like swiper. But maybe it is slightly different for you if you don't care about moving the cursor from the letter row. Often moving from the letters is one reason why people start using vim or emacs. But it is a little bit questionable if it is actually that beneficial. I personally really like it. If you use linux, a fairly similar set of hotkeys is usually the bash standard. In any case you will have to rebind some keys on top of others and adjust them later if you discover that the actually cover some important action. I would just slightly recommend trying to use the default hotkeys as far as possible. It is easier not to invent your own keyboard layout. You can try ergomacs if you must. Thats how I started. Got completely rid of it though. Some seem to be happy with it. PS I really recommend trying org if you haven't. Just write .org instead of .txt when doing notes and stuff. It isn't more difficult than normal text files. You don't need to use any of the features. You need to install the package. PPS Multiple-cursors is amazing get it no matter what. PPPS One useful thing in function keys is recording and using macros. You might want to check that out. Magit is also nice. 👍
cazzipropri · 2022-02-06 22:23
Re: keybindings: the keybindings you are describing are actually not imposed by bash; they come from the readline library. Virtually anything that reads user input via readline will honor those bindings, not just bash. Re: org. I love org. In fact I love org so much that I wrote extra elisp code to emulate some org features on top of markdown-mode. I can't really use org for collaboration because our shop uses Atlassian products, and while bitbucket renders markdown decently with Jira integration, it doesn't render org. People have been asking org rendering in bitbucket for almost 9 years, but atlassian has been sitting on that request (https://jira.atlassian.com/browse/BCLOUD-6569), keeping it in the "gathering interest" stage. I wrote simple calendar integration features, user mention integration and Jira ticket mention integration on top of markdown-mode. But I am digressing. I think we agree on the objective state of the emacs universe, but we diverge on the fundamental philosophy of where to go from here. If you agree with the way I summarize your view, you argue "let's not change the C-n, C-f & al bindings because they have been so established and entrenched in so many modes for so many years, and people rely on them". I'm pushing in the opposite direction: "let's break the C-n, C-f & al bindings precisely because they have been stale for decades, and they stopped making sense a long time ago, more or less when arrow keys started appearing on keyboards." My personal philosophy is that I tend to dislike key combinations, and I like instead single-stroke bindings that preserve their function across modes whenever possible. I have one key for saving, one key for magit-stage, one key for helm-mini, one key to close the current window, etc... The same applies to direction control: we have had arrow keys for decades: cursor movement should only proceed through them.