Emacs Cheat Sheet

Table of Contents

1. Introductions Resources

Before getting much more comfortable with emacs at the point I am today, I tried a bit of everything. Between mastering emacs and finally understanding that every (at least ones I've encountered) shortcut is a command too that can be invoked with M-x <command>, here are all of the primary introduction resources I used.

  1. Start with going through the motions of the built-in tutorial (after installing emacs)
  2. Mastering Emacs - Beginner's Guide - this did some much for me in the realm of being able to apply some of the basic things I did
  3. System Crafters - Beginner's Guide - I found this in the middle of starting to grasp the content and appreciated their content (which includes youtube videos)
  4. The Emacs Manual - this was pretty much in every search and between the first two resources helped me navigate this and ask better question to the web search engines
  5. The Org Manual - and this was in every search that related to org mode

Take away is find a good introduction that resonates with how you pick up an initial concept, and once you start to understand how to ask the right question, the manuals are exceedingly approachable.

Note: I selected a theme that shipped with emacs

2. Shortcut Prefixes and Keyboard Keys

Looks like M-x would would be the Meta Key plus the x key, or Pressing the Alt key on the keyboard then the x key on the keyboard. A common way of showing this in the manual is with something like C-x C-f (find-file) which tells you the command "find-file" (that you can also invokve with M-x find-file), keyboard shortcut is Ctrl + x then Ctrl + f. Knowing the command being invoked by the shortcut is what helped me start to understand the shortcuts more, especially since when I first heard about them someone mentioned that the default shortcuts are to be understood in this other language type way of understanding (which was not useful for my first attempts at emacs years ago).

Name Symbol Keyboard Key
Meta M Alt
Control C Ctrl
Super S Windows
Shift   Shift
     

3. M-x - execute a command, or interactive function

Common or useful commands to execute

3.1. calendar

3.2. eshell

3.3. tetris

3.4. list-packages

3.5. dired - a directory interation

Dired Emacs Manual Page

dired function shortcut description
Quit C-g Quits out of the current function or command
  g refreshes the buffer (showing new or deleted files)
dired-flag-file-deletion d Flags a file for deletion (with a D to the left)
dired-unmark u Removes the deletion flag
dired-do-flagged-delete x deletes teh files flagged for deletion

4. Opening & Savings Files

Description Shortcut
Open a file C-x C-f (find-file)
Saving open file C-x C-s (save-buffer)
Saving to a different file C-x C-w (write-file)
   

5. Interacting with Text

5.1. Copying, Cutting, and Pasting (yank in emacs terminology)

Description Shortcut
Copy selected M-w
Cut selected C-w
Paste (yank) C-y

5.2. Selecting Text

Description Shortcut
Mark beginning of selection C-space

6. Buffers & Navigation

6.1. Buffers

Description Shortcut
Switch Between Buffers C-x b (switch-to-buffer)
kill buffer C-x k (kill-buffer)

6.2. Windows

Description Shortcut
Switch between windows C-x o [as in Oh] (other-window)
Delete window C-x 0 [zero] (delete-window)
Split window side-by-side C-x 3
Split window top and bottom C-x 2
Delete all windows except selected C-x 1

7. Org Mode

7.1. Org Files

Description Shortcut
Toggle the display of inline images C-c C-x C-v (org-toggle-inline-images)
   

7.2. Agenda Files

For the task information to be used in the default views, the file must be added to the agenda files.

Set Directory to use for default agenda files in your .emacs file with

(setq org-agenda-files '("~/path-to-dir"))
Description Shortcut
Add to Agenda Files C-c [ (org-agenda-file-to-front)
Remove from Agenda Files C-c ] (org-remove-file)
   

7.3. TODOs

Description Shortcut
Cycle TODO -> DONE C-c C-t (org-todo)
   

Note that the cycling from TODO to DONE depends on how you have your org task named and set up. With the default setup, this will turn a TODO into DONE.

7.4. Babel, Source Blocks, & Inline Code

7.4.1. Babel

7.4.2. Inline Code

  • monospaced with text encapsulated by the equal sign '='
  • syntax highlighed with src_ <lang>{<code here>}
  • like src_ python{print("hello, world!")}
  • escape character is usually a zero width space inserted with C-x 8 RET 200b

7.5. Org Presentation with org-present-mode

Need to install first. Available in MELPA. M-x list-packages then search for org-present. Mark to install with i. Then install with x. In the org file you want to present from used M-x org-present to start, and M-x org-present-quit to quit it.

7.6. Exporting from Org

Org Mode Exporting If you want markdown support need to add to your .emacs file, (require 'ox-md).

Description Shortcut
Export from Org C-c C-e
Export to html and create file C-c C-e h o

8. Git and Magit

8.1. Basic Magit Usage

Description Shortcut
Clone a repo magit-clone
Status of existing repo magit-status
Once in magit mode, stage files s
once in magit, commit files c c
write the commit message and finalize C-c C-c
Push files P p

Date: 2023-01-05

Author: Russell Brinson