Show Menu
Cheatography

My Emacs Keyboard Shortcuts by

A cheat sheet for most commonly used keyboard shortcuts while writing clojure code, using my emacs config at https://github.com/cmdrdats/emacs-ext

emacs OSX basics

Emacs Key
Name
OSX
M
Meta
Alt - ⌥
C
Control
Ctrl
s
Special
Command - ⌘
S
Shift
Shift
Quick reference on reading emacs keys.
eg: C-M-x = Ctrl + ⌥ + x in OSX. C-s s = Ctrl + s, s

Window Management

M-s-arrow
Flip buffer in direction of arrow
s-arrow
Jump to window in direction of arrow
s-S-arrow
Resize in direction of arrow
C-x 3
Split window vertically
C-x 2
Split window horizo­ntolly
C-x 1
Unsplit everything

Essential emacs

C-x C-f
Open file
s-k
Kill current buffer
C-x b
Switch buffer
C-x C-b
Show buffer list
s-n
Find file in project
M-%
Search and replace in buffer
C-f
Find in buffer
F6
Highlight regex
M-F6
Unhigh­light regex
C-g
Cancel current command
 

nRepl

C-M-x
Evaluate top level form
C-x C-e
Evaluate preceding form
C-c C-b
Interrupt pending evals
C-c C-n
Eval the ns form
C-c M-n
Switch repl to curent ns
C-c C-z
Switch to REPL buffer
C-c M-o
Clear REPL buffer
C-c C-k
Load current buffer
C-c C-l
Load current file
M-.
Jump to def of current symbol
M-,
Return to pre-jump position
M-Tab
Complete symbol at point

Clojure Editing

C-M-Space
Select form after cursor, repeat for multiple
C-Left
Pull closing paren one form back
C-Right
Push closing paren one form forward
C-M-Left
Pull opening paren one form back
C-M-Right
Push opening paren one form forward
ESC-Up
Cut to beginning of form and remove parens
ESC-Down
Cut to end of form and remove parens
M-h
Select current top-level form*
M-i
Jump to symbol in current buffer
*actually works with empty lines, not forms. But due to the way clojure is idioma­tically written, this trick works well.
 

Handy commands (M-x)

cider
Open a new nRepl connection
cider-quit
Close nRepl
ack
Regex across your current project
make-d­ire­ctory
Create folder
dired
List and manage folders

Summary

 
You'll want to grab my config file off https:­//g­ith­ub.c­om­/cm­drd­ats­/em­acs-ext . This sets everything up from a basic emacs 24 instal­lation.
               
 

Comments

I've never learned emacs and thought this would help me. But it looks to me, as a beginner, that some things are missing. How do I close a file without saving? How do I exit emacs? How do I save a file? Can I have multiple files open? How do I compile programs?

I'm not sure what all could be added to this. I'm not qualified to critique or even suggest. But it just felt like a few more commands might help someone who's trying to learn emacs.

Add a Comment

Your Comment

Please enter your name.

    Please enter your email address

      Please enter your Comment.

          Related Cheat Sheets

          Sublime Text 2 - Shortcuts (Verbose Mac) Keyboard Shortcuts
          Spacemacs (+Clojure) Keyboard Shortcuts

          More Cheat Sheets by CmdrDats