reddit / emacs
If you're new to Emacs, I need your help
vale_fallacia · 2022-03-15 10:56
I've copied a good Emacs navigation cheat sheet, but have extra space left over. What sort of things do you, the newbie Emacs user, want displayed in the empty space in [this diagram](https://gist.github.com/anthonyclarka2/749d89c94c6229fabe8cd00d5fb96a3a)?
I copied this diagram by Martin Grund from https://punchcard.wordpress.com/2010/10/09/emacs-movement-shortcuts-wallpaper/ with the aim of making a printable version. If you want to edit it yourself, I've got the original .drawio file in the gist too, but it only renders as text. You'd have to save it and open it with https://www.diagrams.net/ or the application you can download from there.
I am still trying to figure out the best presentation of the printable version, so any general suggestions will be very much appreciated. The aim is to have something that will be visible and useful printed on a sheet of Letter or A4 paper, viewed from about 3 feet away. (in other words, the distance from my eyes to the patch of wall where I've got a copied pinned up!)
rguy84 · 2022-03-15 11:58
Honestly, I would leave it. If I am that new, and need to print it out, there's enough there to keep me busy for a while. I'd be mindful of terms. You used kill/yank and cut/paste. If totally new, kill hasn't clicked yet, so consider Kill (cut).
vale_fallacia · 2022-03-15 12:02
> consider Kill (cut)
That's good advice, thank you!
yal_g · 2022-03-15 12:10
> I am still trying to figure out the best presentation of the printable version, so any general suggestions will be very much appreciated.
For a cheat sheet, as a beginner that constantly needs to refer to his own notes while using Emacs, I would say the best one would the simplest/quickest one to read. Not having to look at it, wondering where is the action and the associated shortcut I need.
As a teacher in a previous life and as much as I can tell, a shortcut is *almost never* what a beginner is searching for. Because if he/she already knew the shortcut there would be no need to search for it. What the beginner is looking for are *actions*. What can be done, not how they must be done.
*I want to cut, paste, move a line up, move a screen down, open a file, create a file,...* The shortcut, or the command, is the answer to that demand. Quickly finding an action on a cheat sheet is what will quickly brings the associated shortcut/command ;)
So, looking at your SVG (I am not sure to understand its visual repartitions though, so take that into account) I would make the actions themselves central with their name in a big and bold face, and below each I would put the associated shortcut in a smaller and thinner face.
Hope this help.
vale_fallacia · 2022-03-15 12:37
> I would make the actions themselves central with their name in a big and bold face
Hmm, that's something I'll have to try. You're absolutely right though! I'll have to consider whether visual/positional memory comes into play, but I haven't used it for myself long enough yet. In other words, as the user learns the shortcuts, would they start to rely on where the shortcut is on the diagram? But if they're completely new, then they will indeed be looking for the description first. Interesting, I (obviously) hadn't considered this! Thank you very much! :)
vale_fallacia · 2022-03-15 12:42
> I am not sure to understand its visual repartitions though
Sorry for the second reply but this is something I'm trying to figure out how to make more clear. I have forwards, backwards, up and down, but I could definitely be more clear about what that means. So "Up" means "moving up in the editor/screen", etc etc.
I need to add some light grey arrows I think, and maybe an explanation of the "compass" like layout. Lots to think about, lol :)
wanderlustking · 2022-03-15 14:36
Placing mark is missing. I’m sure loads of new user try to select with mouse or press shift and arrow key but don’t get their desired result. So C-Spc
thetemp_ · 2022-03-15 15:23
It looks like you removed "C-l" from the middle of the original diagram. Maybe that's because it moves your view of the screen and not the cursor within the buffer.
In case you want to replace it, "M-r" would be more relevant for "movement-to-the-middle".
Also, maybe a little nit-picky, but the portion titled "Buffers" is actually about windows not buffers.
If you have more room, you can add C-M-f and C-M-b, but I think you'd want to come up with something other than "sexp" to describe their movement. In regular text, they move across quotations, parentheticals, and hyphenated words.
There's also M-a and M-e for sentence movement.
emoarmy · 2022-03-15 15:31
If you haven't seen it, /u/sachac also has a good cheatsheet, you might be able to get inspiration from https://sachachua.com/blog/2013/05/how-to-learn-emacs-a-hand-drawn-one-pager-for-beginners/
00-11 · 2022-03-15 18:26
Here are some commonly useful keys. You might want to consider some of them:
Select, copy, kill selection (region):
C-SPC = set-mark-command
C-@ = set-mark-command
C-w = kill-region
S-delete = kill-region
C-M-w = append-next-kill
C-S-delete = append-next-kill
M-w = kill-ring-save
C-insert = kill-ring-save
M-delete = kill-ring-save
mouse-3 = mouse-save-then-kill
C-x SPC = rectangle-mark-mode
Select things:
C-M-@ = mark-sexp
M-h = mark-paragraph
C-x C-p = mark-page
C-x h = mark-whole-buffer
Kill/delete/yank things:
DEL = backward-delete-char-untabify
C-k = kill-line
C-delete = kill-paragraph
C-backspace = backward-kill-paragraph
C-d = delete-char
M-d = kill-word
M-DEL = backward-kill-word
C-M-k = kill-sexp
C-M-delete = kill-sexp
C-M-backspace = backward-kill-sexp
M-k = kill-sentence
C-x DEL = backward-kill-sentence
C-delete = kill-paragraph
M-S-delete = kill-rectangle
M-S-backspace = clear-rectangle
M-S-delete = kill-rectangle
M-S-insert = yank-rectangle
M-z = zap-to-char
Move things:
C-t = transpose-chars
M-t = transpose-words
C-M-t = transpose-sexps
C-x C-t = transpose-lines
Move cursor:
C-x C-SPC = pop-global-mark
C-x C-@ = pop-global-mark
C-x C-x = exchange-point-and-mark
M-< = beginning-of-buffer
C-home = beginning-of-buffer
M-> = end-of-buffer
C-end = end-of-buffer
C-n = next-line
C-p = previous-line
C-f = forward-char
C-b = backward-char
M-f = forward-word
M-b = backward-word
C-M-f = forward-sexp
C-M-b = backward-sexp
M-e = forward-sentence
M-a = backward-sentence
M-} = forward-paragraph
C-down = forward-paragraph
M-{ = backward-paragraph
C-up = backward-paragraph
C-x ] = forward-page
C-x [ = backward-page
M-n = forward-to-indentation
M-m = back-to-indentation
M-_ = forward-whitespace
C-s = isearch-forward
C-r = isearch-backward
C-M-s = isearch-forward-regexp
C-M-r = isearch-backward-regexp
Scroll, move cursor in window:
C-M-l = reposition-window
M-r = move-to-window-line-top-bottom
M-v = scroll-down-command
prior = scroll-down-command
C-v = scroll-up-command
next = scroll-up-command
M-prior = scroll-other-window-down
C-M-v = scroll-other-window
M-next = scroll-other-window
C-x < = scroll-left
C-next = scroll-left
C-x > = scroll-right
C-prior = scroll-right
Insert, fill:
insert = overwrite-mode
M-q = fill-paragraph
M-SPC = just-one-space
C-x i = insert-file
C-x f = set-fill-column
Split, delete, select, resize windows:
C-x 0 = delete-window
C-x 1 = delete-other-windows
C-x 2 = split-window-below
C-x 3 = split-window-right
C-x o = other-window
C-x ^ = enlarge-window
C-x } = enlarge-window-horizontally
C-x { = shrink-window-horizontally
Buffers:
C-x b = switch-to-buffer
C-x C-b = buffer-menu
C-x k = kill-buffer
Files, directories:
C-x d = dired
C-x f = find-file
C-x C-r = find-file-read-only
C-x C-v = find-alternate-file
C-x C-w = write-file
Indent:
TAB = indent-for-tab-command
C-x TAB = indent-rigidly
Help:
C-x = = what-cursor-position
C-h a = apropos-command
C-h b = describe-bindings
C-h d = apropos-documentation
C-h e = view-echo-area-messages
C-h f = describe-function
C-h F = Info-goto-emacs-command-node
C-h i = info
C-h k = describe-key
C-h K = Info-goto-emacs-key-command-node
C-h l = view-lossage
C-h m = describe-mode
C-h o = describe-symbol
C-h p = finder-by-keyword
C-h P = describe-package
C-h r = info-manual
C-h S = info-lookup-symbol
C-h t = help-with-tutorial
C-h v = describe-variable
C-h w = where-is
General:
C-x ( = kmacro-start-macro
C-x ) = kmacro-end-macro
C-x e = kmacro-end-and-call-macro
C-x C-c = save-buffers-kill-terminal
C-x C-q = read-only-mode
C-x C-s = save-buffer
C-x s = save-some-buffers
C-x M-: = repeat-complex-command
C-x M-ESC = repeat-complex-command
C-/ = undo
C-_ = undo
C-x u = undo
C-x z = repeat
C-x ` = next-error
11fdriver · 2022-03-15 23:32
I've got a few ideas about the empty spot.
I use the keyboard macro feature constantly to cut down on repetitive editing:
* *C-x (* \- `kmacro-start-macro` (record).
* *C-x )* \- `kmacro-end-macro` (stop).
* *C-x e* \- `kmacro-end-and-call-macro` (replay).
Commenting is common and intuitive in Emacs:
* *M-;* \- `comment-dwim` (new comment).
* *C-x C-;* \- `comment-line`
Query-replace is convenient, more so than some think:
* *M-%* \- `query-replace`
* *y*/*SPC* \- replace current match, and move to next.
* *n*/*Backspace* \- skip and next.
* *!* \- replace all remaining matches at once.
* *u* \- undo last replacement.
* *e* \- edit replacement string.
* *M-% M-p* \- Edit last `query-replace` statement.
I know you're probably avoiding making this too big (it is a cheat sheet after all), but I feel there are a few things missing (for me at least).
# Killing & Yanking
* Add a note that this is Emacs-talk for 'copying & pasting'.
* N.B. *C-d* is a deletion command, not a kill!
* Since you're including the region-kill/yank binds, you'll probably want some region-making binds.
* *C-SPC* \- `set-mark-command`
* *C-x C-x* \- `exchange-point-and-mark`
* *M-h* \- `mark-paragraph`
* *C-x h* \- `mark-buffer`
* Maybe mentioning `cua-mode` would be good here, too.
# Other
* *C-l* \- `recenter-top-bottom` (and redraw screen if it's junked).
* *C-g* \- `keyboard-quit` (cancel current keypress/command).
* *C-h C-h* \- help menu; Emacs' best feature is that it's self-documenting.
* *M-x* \- `execute-extended-command`
* *C-/* or *C-x u* \- undo.
* *C-x C-c* \- `save-buffers-kill-terminal` (save and exit).
# Buffers
* Split into 'Files', 'Buffers', and 'Windows'
* *C-x C-f* \- `find-file`
* *C-x C-w* \- `write-file` (save as).
* *C-x d* \- `dired` (file manager).
* *C-x C-s* \- `save-buffer`
* *C-x b* \- `switch-buffer`
* *C-x C-b* \- `buffer-menu`
* *C-x k* \- `kill-buffer` (i.e. delete buffer).
It might be worth putting in a note that *M-* refers to *Alt-* and *C-* refers to *Control-*. It might seem obvious, but it can really trip you up if you aren't expecting it.
[deleted] · 2022-03-15 23:34
[deleted]
Specific-Principle94 · 2022-03-16 09:56
The way I have been learning emacs is from 1997 O'Reilly Learning emacs 2nd edition.
All I want is an up to date book that goes over most functionality. It came with a really good cheat sheet that I can have at my desk
Status-Detective-783 · 2022-03-16 22:48
I think that newbies should quickly learn C-h h, C-h a, and C-h l (lower case L). The last one because you'll OFTEN hit the wrong key bindings, and lossage will tell you what the heck you just did. That's the minimum for "learning" stuff.
Then there's the "uh oh" set: C-/ undo, C-g cancel, and ESC ESC ESC which is a stronger form of cancel.
lstrang · 2022-03-20 08:38
Here's one I missed, but it incredibly useful:
C-M-n and C-M-p
They go forward and backward by "lists" which are defined for each major mode, so when on a "begin" in ruby, C-M-n takes you to the corresponding "end" and vice-versa. It is in some ways like the % in vim.
vale_fallacia · 2022-03-20 12:22
About to work on it again now I have some time, definitely going to incorporate that - very useful :)
GarethLagerwall · 2022-03-22 12:42
I am starting to use C-M-b and C-M-f for skipping back and forward between pairs of parentheses. It is quite useful, especially when you start getting into elisp, or at least configuring your init file.
GarethLagerwall · 2022-03-22 12:44
I didn't see this, and posted the same comment. Its super useful, and not immediately obvious for noobs
getpoked · 2022-03-23 00:39
I've been using tab-bar mode a ton as someone moving over from vs code to emacs this year. I really like having separate workspaces for separate workflows like docs vs python. I keep a tab for each task. I think the binds for this next to the buffer commands could be good
Wiz21c · 2022-03-28 19:11
A bit of a joke but : a shortcut to enable CUA mode would be nice :)