Skip to content

Latest commit

 

History

History
481 lines (382 loc) · 18.1 KB

CheatSheet.org

File metadata and controls

481 lines (382 loc) · 18.1 KB

Reference Sheet for Emacs

f7 preview changes f8 commit each change f9 push changes

Start a numbered list from any number using the syntax “N. [@N] ⋯”, a nice way to have 0-numbered lists or lists with text in between that does not reset the numbering.

  • Emacs CheatSheet
    M-n 𝕏 / C-u n 𝕏
    Repeat command 𝕏 $n$ times.
    • n may be omitted in the second form, defaulting to 4.
    • Whence, it may be stacked: “C-u ⋯ C-u 𝕏” repeats command 𝕏 4ⁿ-times where n is the number of C-u commands.
    • Holding Alt key and press 1 then 2 then 3 then release the Alt key, and, say, press the j key. Now you have 123 j’s inserted lol.

Header

begin multicols

Why?

I have so many things installed, I’m forgetting some of the stuff that I installed to be more productive! Whence this “personal” cheat sheet. —I’m not trying to be comprehensive; see the existing cheatsheets for Emacs and Org.

There are already cheatsheets for Emacs, Org, and even Elisp; so why bother with another one? The general ones are great but contain stuff I rarely use, such as information on registers, but are missing stuff I’d like to know, such as Helm keybindings which are not shipped with Emacs.

Below are the bindings that are shipped with Emacs or the packages one installs. To be somewhat useful to others, my personal bindings will be “enclosed” in quotes. I will write X,Y-x,y to denote one of X or Y followed by one of x or y; e.g., C,M-d denotes C-d and M-d –for character and word deletion, respectively. Hopefully this makes it easier to group related commands.

As always, since I’ve installed which-key, it suffices to press a prefix then look at the resulting menu 😃

C-h C-hHelp for the help command
C-h hLearn how to say ‘hello’
C-h tRead the Emacs tutorial
C-h mHelp for current mode
C-h bDescribe all key bindings
C-h i m emacsRead the Emacs manual

In nearly every Emacs application, press

?, h
Obtain help; see listing of possible commands.
q
Quit current application, closing buffer.

Use Emacs in any text area on my OS with Cmd Shift e.

Getting Help

{{{no-vertical-padding(2.5)}}}

C-h oDescribe symbol at point; best one.
C-h k,f,mDescribe key press, function name, or mode
C-h aApropos: Show commands matching a string
C-h eOpen *Messages* buffer in another window
C-h iEnter Info documentation reader
In Info:
hRun Info’s tutorial
iLookup item using index
mSelect menu item by name
gGo to any node, by name
spc, delScroll down, up
n, pNext, previous topic node
bBeginning of node
dReturn to main directory node

Windows

{{{no-vertical-padding(2)}}}

C-x 0,1Delete this, other windows
C-x 2,3Split window above, to the side
C-x oSwitch cursour to other window
C-x ^Increase window height
C-x {,}Shrink, widen window

Using C-x 5 ... in place of C-x ... operates on the ‘frame’ level –i.e., other Emacs GUI instances. C-x 4 ? is for acting on the other window, where ? = f, d, b for finding file, directory, buffer. Perhaps most useful is C-x 4 c for working with different parts of the same buffer.

C-x 4 c clone-indirect-buffer-other-window. It splits the current window, clones the current buffer and visits the clone in the newly opened window.

C-x 2 splits and copies the current buffer, but it’s inappropriate for looking at one part of the buffer while working on another part since every editing change happens live, including superficial visual changes such as region folding and narrowing. Instead, we select the region we’re working on, for example, then press C-x 4 c C-x n n to clone the buffer then to narrow the region we’re working on.

“s-<arrow>”Jump to window via arrow key
“M-<tab>”Flip to next buffer
“M-S-<tab>”Flip to previous buffer

All commands are prefixed by C-x x; main commands:

sSelect a space to go to or create it.
n,→, p,←Next, previous space
cQuery a perspective to kill.
rRename a perspective.
AAdd buffer to current perspective & remove it from all others.

{{{no-vertical-padding(1.5)}}}

  • C-x u Visualise undo tree.
    • t, d toggle timestamps and diff display.
    • M-{,} Go to previous, next branching point.
    • q Exit at currently selected state.
  • C-x r u Save current buffer state.
  • C-x r U Restore saved buffer state.

Save & restore is useful for experimenting with a function definition, for example.

Undo Tree also has functions which save an undo state to a register and which restore a save state from a register. These are bound to C-x r u and C-x r U by default. These are great for things like experimenting with a function definition.

Killing

{{{no-vertical-padding(2)}}}

C,M-dforward kill character, word
C,M-delbackward kill word prefix
C-k , “M-k”forward, backward kill line
C-x delbackward kill sentence
C,M-wKill, copy region
C-x r kKill region
C-x C-oDelete all but one consecutive blank lines
M-yShow kill ring, with “helm”

Marking

{{{no-vertical-padding(2)}}}

C-SPCSet mark
C-x C-xExchange point & mark
C-x hMark buffer
[C-u 𝓃] M-@Mark a / 𝓃 words away
M-hMark current paragraph

columnbreak

\columnbreak

Formatting

{{{no-vertical-padding(2)}}}

By default C-t is transpose characters; I’m using it quickly open a terminal.

C-M-\Indent region, mode dependent
C-x tabIndent region arg columns or ←,→
M-;Toggle comment region
C-c ;Org toggle comment subtree
C-M-oMove rest of line vertically down
M-u,lUpcase, downcase rest of word
C-x C-u,lUpcase, downcase region
C-x r tPrepend string to marked lines
M-tTranspose current word with next
C-x C-tTranspose current line with above

Dictionary & Thesaurus

{{{no-vertical-padding(1.5)}}}

M-$Spellcheck word
“M-#”Synonym for word
“M-!”Define word
“M-^”Grammar check region
“C-c t”Google translate region

Textual Navigation

{{{no-vertical-padding(1)}}}

C-b, f←, → character
M-b, f←, → word
C-p, n↑,↓ line
M-g ggo to a line
C-a, estart, end line
M-a, estart, end sentence
M-{, }start, end paragraph
M-<, >start, end buffer
C-vdown page
M-vup page
C-lcentre page
M-rrelocate point
C-l reorients the buffer so that the current line is at the top/center/bottom of the screen. Whereas M-r moves the point to top/center/bottom without recentering the window.

Org-mode: All commands are prefixed by C-c.

n,pnext, previous heading
f,bn,p same level heading
C-ubackward to higher heading
C-j↑↓ jump to another heading
“C-h”Fold current tree

Using the “super key” to navigate between org blocks.

“s-p,n”Previous, next src block
“s-e”Toggled editing src block
C-x mCompose
C-c C-sSend
M-x gnusRead mail

Then,

RETOpen article
B mMove an article
!Mark as read, but it keep around
dMark as read; archive it.
RReply in-place.
rReply in clean slate.

Delete an article by moving it to ‘Trash’.

{{{no-vertical-padding(2)}}}

M-/Expand previous word dynamically
M-<digit>Select one of the 10 suggestions

Narrowing

{{{no-vertical-padding(1)}}}

This allows us to “zoom in” or “focus” on a particular region; the rest of the buffer is ‘hidden’. All commands begin with C-x n.

nNarrow to region
wWiden to full view
eNarrow to org element
sOrg narrow current tree

Searching

{{{no-vertical-padding(2)}}}

C-sSearch current buffer
“C-M-s”Search all buffers
“C-S-s”Back to where search began
M-s M-wSearch region in Web

C-c C-e during a search to make live edits.

Org Visibility

{{{no-vertical-padding(2)}}}

tabCycle visibility
S-tabCycle global visibility
C-c C-x C-vToggle inline image display
C-c C-x C-lToggle, preview, LaTeX for tree

Structure Editing

{{{no-vertical-padding(3)}}}

<return>Newline with indentation
M-<return>Newline with new org item
M-S-<return>Ditto, but with a TODO marker
C-M-<return>Newline, cursor at start
C-<return>New heading after current content
C-S-<return>Ditto, but with a TODO marker
C-c -,*Demote, promote headings to items
M-←,→Promote, demote heading
C-c C-tSet state of tree
C-c , A,B,CSet priority A, B, or C for tree
C-c , SpcRemove priority from tree
C-c C-x p,eSet property, effort of tree
M-↑,↓Move any org element up or down
M-S-↑,↓Move a line up or down
C-c cCapture new item
C-c C-x C-aArchive tree

Babel

{{{no-vertical-padding(2)}}}

C-c C-cExecute code block
C-c C-v jInsert header argument
C-c C-v IView, possibly global, header info
C-c C-v gGo to named block
C-c C-v n,pGo to next, previous block
C-c C-v dDemarcate, split up, code block
C-c C-v tTangle all blocks in buffer

Misc

M-x list-input-methods show all input methods

C-c C-x iCapture column view in dynamic block
C-+Increase text size
C--Decrease text size
“C-x d”Toggle Neotree file browser
“C-c C-m”Re-compile; execute local compile command
“<f5>”, s-rReload buffer from disk
“C-∣”Swap 2 horizontal windows to vertical
“C-t”Quickly pop-up a terminal
C-c C-oOpen link at point

Org Speed Keys

{{{no-vertical-padding(1)}}}

With cursor at the beginning of an org headline:

#Toggle COMMENT-ing
tSelect state
sToggle narrowing
I,O,EClock in, out; add effort
p,nPrevious, next heading
f,bp,n for same-level
uUpward to parent
cCycle visibility
wRefile, relocate
^Sort children trees
D,UMove heading down, up
L,RPromote, demote
1,2,3Select priority
?See possible keys

Timestamps

{{{no-vertical-padding(2)}}}

C-c .Prompt for date & insert timestamp
C-c C-dInsert deadline for tree
C-c C-sSchedule a tree
S-↑,↓,→,←Alter timestamp by a day →←, year ↓↑
C-c C-x C-tGlobally toggle date display

Clocking Time

{{{no-vertical-padding(2)}}}

C-c C-x C-i,oStart, stop clock on tree
C-c C-x C-rInsert, update, clock report
C-c C-x C-eInsert effort for current clock

Agenda

{{{no-vertical-padding(2.5)}}}

C-c cCapture an idea quickly
C-c aOpen agenda to see tasks
C-c jDiscuss what’s accomplished
C-c C-zAdd note to current tree
C-c C-sSchedule a task
C-c C-aArchive a task
C-c a aSee agenda for the week
“C-c a c”See completed tasks
“C-c a u”See unscheduled tasks
C-c a tCompile global todo list
C-c C-x bOpen agenda task in dedicated indirect buffer
FToggle follow mode: See details as you navigate
vChange agenda view, e.g., to day or month
f / bForward, backward a view, e.g., day or month
RSee report of total clocked time
. / jGo to today, or prompt for a date
e, t, aRemotely set effort, state, or archive
I, O, XStart, stop, cancel clock on current item
C-c C-x C-rSee clocked times report

end multicols