Skip to content

Instantly share code, notes, and snippets.

@billturner
Created June 12, 2018 03:03
Show Gist options
  • Save billturner/e873ce69ce03487c84607c569304df80 to your computer and use it in GitHub Desktop.
Save billturner/e873ce69ce03487c84607c569304df80 to your computer and use it in GitHub Desktop.
emacs: commands
Some custom ones:
C-x f - find file in project
C-x a - ack/ag in project
C-x t - toggle neotree
C-x m - magit status
C-c TAB - helm buffer list
Common combos:
M-b M-d - move to beginning of word, kill word
M-| enter "pbcopy" - will copy selected region to osx clipboard
M-! then enter command to run on shell
C-x b RET - use back and forth to switch between 2 last used buffers
# Movement
C-v down a page
M-v up a page
M-r cycle point between top, middle, and bottom of current view
# Editing
C-d kill letter under cursor
M-d kill to end of word under cursor / next word
C-k kill to end of line
C-x h select full document
C-<SPACE> start marker for highlighting
C-n / C-p expand highlight down or up
C-w kill the selected region
M-w copy the selected region
C-y paste last thing killed/copied
M-y cycle through recent kills/copies
M-; comment/uncomment current line, or selected region
C-x > indent current line or region 2 spaces
C-x < unindent current line or region 2 spaces
C-@ expand region
C-x C-t flip current line with one above it
# Search and replace
C-s search forward in current buffer
C-r search backwards in current buffer
C-s C-w opens search prompt with word under cursor filled in
M-x query-replace
specify what to search for, and what to replace with
* will ask you to verify each replace
* press y (or SPACE) to replace selected item
* press n to not replace
M-% Same as above
# Edit utilities
M-u uppercase word (if at beginning of word)
M-l lowercase word ( "" )
M-c capitalize word ( "" )
M-/ autocomplete word based on current buffer
M-$ check spelling of word under cursor (ispell must be installed)
Also available:
M-x ispell-buffer
M-x ispell-region
# Org mode
<TAB> collapse/expand section
S-<TAB> collapse/expand all sections
M-S <up/dn> move subtree up or down
M-S <rt/lft> demote/promote subtree (and children)
C-c C-t toggle todo status
S-<rt/lt> " (need to double check)
C-c C-w move current item under another (will be prompted)
C-x n s narrow down on current subtree
C-x n w to widen back to full doc
C-c o open personal Todo file
C-c w open work Todo file
C-c C-x C-a archive current entry
# lisp & slime
M-x slime to start up slime REPL
In editor:
C-c C-c to compile the current function at point, loading in SLIME
C-c C-k to compile the current file, loading in SLIME
C-c C-z to switch to REPL
C-c M-o clear REPL buffer
M-n slime-next-note
M-p slime-prev-note
M-. jump to function declaration
M-, jump back to where you came from
C-c C-c C-d describe symbol
C-c C-] slime-close-all-parens-in-sexp
C-c TAB slime-complete-symbol
C-c C-t slime-toggle-fancy-trace (and un-trace)
C-c C-w C-c slime-who-calls
C-c RETURN macroexpand interactively
C-c M-d disassemble a function
C-c I slime-inspect
C-h m
In REPL:
, brings up command list
choose "quit" or "sayonara" to exit
# Upgrading packages
M-x package-list-packages
will update list of all packages available
and show list.
U mark all packages upgradable to upgrade
x upgrade all marked packages
# Help
C-h f find definition for function
----
C-l Center on cursor, 2x to take line to top of page
C-f Move forward a character
C-b Move backward a character
M-f Move forward a word
M-b Move backward a word
C-n Move to next line
C-p Move to previous line
C-a Move to beginning of line
C-e Move to end of line
M-a Move back to beginning of sentence
M-e Move forward to end of sentence
M-< beginning of doc
M-> end of doc
C-u NUMBER C-n Down NUMBER lines
C-u NUMBER C-p Up NUMBER lines, etc
<DEL> Delete the character just before the cursor
C-d Delete the next character after the cursor
M-<DEL> Kill the word immediately before the cursor
M-d Kill the next word after the cursor
C-k Kill from the cursor position to end of line
M-k Kill to the end of the current sentence
C-x C-f Find file
C-x C-s Save file
C-x s Save some buffers
C-x C-b List buffers
C-x b Switch buffer
C-x k close current buffer
C-x C-c Quit Emacs
C-x 1 Delete all but current split
C-x u Undo
C-s for forward search
C-r for reverse search
C-x 2 splits the screen into two horizontal windows
C-x 3 splits the screen into two vertical windows
C-x o jumps to other window
C-x 1 delete all but one window
C-M-v scrolls/pages other window
C-space to set a mark, then text between that and cursor you can kill (C-w), or copy (M-w)
C-x C-x to switch mark & cursor positions - like a temp bookmark
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment