Skip to content

A handy list of essential key bindings to commands in Emacs

Notifications You must be signed in to change notification settings

leeorengel/my-emacs-keybindings

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

88 Commits
 
 

Repository files navigation

My Emacs keybindings

This page assumes you are using my emacs config at http://github.com/leeorengel/.emacs.d

This page has been organized roughly in order of importance in terms of the minimum keybindings you need to know to get going in emacs. Subsequent sections include more advanced groupings of keybindings.

Table of Contents

Basic

Keybinding Spacemacs Keybinding Description
C-x C-x M-q Quit
C-x C-s M-s Save
SPC f e R Reload config
SPC f e d Open .spacemacs

Navigation

Within a buffer

Basic Motion

Keybindings for very basic cursor movement.

Keybinding Spacemacs Keybinding Description Notes
C-p k move cursor to previous line
C-b h move cursor backward one character
C-f l move cursor forward one character
C-n j move cursor to next line
C-S-p 5k move cursor up 5 lines (e.g. faster) Custom keybinding courtesy of magnars
C-S-n C-e move cursor down 5 lines (e.g. faster) Custom keybinding courtesy of magnars
M-b b move cursor to previous word
M-f w move cursor to next word
C-M-b ( move cursor to previous s-expression
C-M-f ) move cursor to next s-expression
C-a 0 Go to beginning of line
C-e $ Go to end of line
f<char> Go to next occurrence of char on line
F<char> Go to previous occurrence of char on line
t<char> Go to next occurrence before char on line
T<char> Go to previous occurrence before char on line

Jumping Around

Keybindings for jumping around inside a single buffer.

Keybinding Spacemace Keybinding Description Notes
s-[ s-[ Previous cursor position within buffer Custom keybinding
s-] s-] Next cursor position within buffer Custom keybinding
M-< gg Go to beginning of buffer
M-> G Go to end of buffer
M-g g :X Go to line number X
C-l M Center screen at cursor/point
M-v C-u Scroll to previous screen
C-v C-d Scroll to next screen

Jumping Around (Avy)

Keybinding Spacemacs Keybinding Description
jj SPC SPC Jump to char
jk Jump to consecutive chars
jl SPC y Jump to the beginning of a line (avy-goto-word-1)
xx SPC : Executed extended command(execute-extended-command)

Across buffers

Keybindings for moving in between open buffers.

Keybinding Spacemacs Keybinding Description
C-x SPC b p Previous buffer/file
C-x SPC b n Next buffer/file

Selection/Copy/Paste

Commands for selecting, cutting, copying and pasting regions of text.

Keybinding Spacemacs keybinding Description
C-SPACE SPC v Mark the beginning of a selection
C-x C-x o Toggle between beginning and ending of selection
M-w y Copy selection
C-w d Cut and copy selection
C-y p Paste (yank from kill ring)
C-x h Select entire buffer region

Expand Region

Keybinding Spacemacs keybinding Description
C-= SPC v Initiate expand region
C-= v Expend region by semantic unit
C-- V Contract region by semantic unit
r Reset the region to initial selection
C-g ESC Leave expand-region mode

Selection advanced

Keybinding Spacemacs Keybinding Description Notes
C-M-@ Select s-expression
C-M-h Select function

Editing

Keybindings for making changes within a buffer.

Keybinding Spacemacs Keybinding Description Notes
C-/ u Undo
C-S-/ C-r Redo
C-x u SPC a u Undo tree visualize
C-Shift-Del dd Delete current line
C-k d$ Delete rest of line from cursor
M-0 C-k d0 Delete from cursor to beginning of line
M-Del db Delete previous word
M-d de Delete next word
daw Delete current word
C-c d yyp Duplicate current line
C-x C-t SPC x t l Swap line with line above
M-z df delete up to char Keep hitting char to go to next occurrence. C-K to delete.
M-\ delete all surrounding whitespace and tabs around cursor

Evil

Evil Editing

Keybinding Description
r Replace a single character
cc Change/replace entire line
cf<char> Change/replace to first occurrence of char from current position on current line
ct<char> Change/replace up to first occurrence char from current position
cw Change/replace to end of word
c$ Change/replace to end of line

Evil Visual Mode

Keybinding Description
aw Select a word
ab Select a () block
aB Select a {} block
ib Select inner () block
iB Select inner {} block

Evil Searching

Keybinding Description
/ followed by a regex, then RET Search within current buffer
? followed by a regex, then RET Search backwards within current buffer
n Next occurrence in search
N Previous occurrence in search
:%s/old/new/g Search/replace old with new globally in buffer
* Search for next occurrence of word at cursor
# Search for previous occurrence of word at cursor

Transposing

Keybinding Spacemacs Keybinding Description
M-t l SPC x t l Transpose lines
M-t w Transpose words
M-t s Transpose s-expressions
M-t p Transpose params

Searching/Replacing

Keybinding Spacemacs Keybinding Description
C-s SPC s b Find next occurrence in buffer
SPC s p Search within project
C-r Find previous occurrence in buffer
C-M-s Find next occurrence using regex in buffer
C-M-r Find previous occurrence in buffer

File Management

Keybinding Spacemacs Keybinding Description Notes
C-x b RET SPC b b Create a new/open recent buffer
C-x 4 b RET Create a new buffer in new window
C-x C-f SPC f f Open a file
C-x f SPC f r Open recent file
C-x k RET SPC b d Close buffer
SPC b R Reload buffer
C-x C-s SPC f s Save buffer
C-x C-w RET SPC f s Save buffer to file
C-c D SPC f D Delete current buffer & file custom keybinding
M-x SPC : Enable mode in file

Directory Management

Keybinding Spacemacs Keybinding Description
C-x d SPC a d Open Dired
< Previous directory in listing (skips files)
> Next directory in listing (skips files)
f Open file
v View file
^ Go up to parent directory
d Mark file for deletion
x Delete files marked for deletion
q Quit
+ Create directory
= Compare file at point with previously marked file
m Mark a file for action
u Unmark a file for action
t Toggle marking
! <shell command string> Run shell command on file at cursor

Window Management

Keybinding Spacemacs Keybinding Description
C-x 1 SPC w m Close all other windows except current window
C-x 2 SPC w s Split current window horizontally
C-x 3 SPC w v Split current window vertically
C-x 0 SPC w c Close current window
C-x o SPC TAB Switch to next window
M-- C-x o Switch to previous window
M- C-x o Jump ahead # of windows
C-M-Shift-v Scroll backward other window
C-M-v Scroll forward other window
C-x { Shrink window narrower
C-x } Grow window wider
SPC w = Balance split windows
SPC <window_num> Jump to window number

Windmove

Keybinding Spacemacs Keybinding Description
S-<left> Move to window to the left of current window
S-<right> Move to window to the right of current window
S-<up> Move to window above current window
S-<down> Move to window below current window

Frame Management

Keybinding Spacemacs Keybinding Description
C-x 5 1 Close all other frames except current frame
C-x 5 2 Split current frame horizontally
C-x 5 0 Close current frame
C-x 5 o Switch to next frame
C-x C-n Create new frame

Projectile

Project navigation. An alternate prefix is Command-P.

Keybinding Spacemacs Keybinding Description Notes
M-S-o (default is C-c p f) SPC p f Open file in project with completion Custom keybinding
M-S-f (default is C-c p s s) SPC p s Search all files in project using regex Custom keybinding
M-e (default is C-c p e) SPC p r Show all recent opened files in project Custom keybinding
C-c p F Open file in ANY project with completion
C-c p r Find/replace all files in project
C-c p b Show all open project buffers
C-c p p SPC p p Switch between known projects
C-c p D Open root project in dired
C-c p k Kill all buffers in project
C-c p ! Run shell on root of project as current dir
C-c p p Show all known projects

File Navigation (NeoTree)

Keybinding Spacemacs Keybinding Description
<f8> SPC f t Toggle project explorer
RET RET Open file in main window
# RET Open file in window #
| | Open file in vertical split
- - Open file in horizontal split
C-c C-n c Create a new file or dir if filename ends with '/'
C-c C-d d Delete a file or a directory
C-c C-r r Rename a file or a directory
g gr Refresh project explorer
U U Go up one node in tree
D D Go down one node in tree
H Previous sibling
L Next sibling
A TAB Toggle widening explorer window
S H Go to previous sibling node in tree
s L Go to next sibling node in tree
H s Toggle showing hidden files

Multiple Cursors

See https://github.com/magnars/multiple-cursors.el

Keybindings Description Notes
C-S-c C-S-c Mark consecutive lines with multiple cursors First select lines
C-< Mark previous occurrence of word First select word
C-> Mark next occurrence of word First select word
C-c C-< Mark all occurrences like selection

Commenting

Spacemacs Keybinding Description
SPC ; Comment to end of line
SPC c l Comment lines
SPC c L Invert Comment lines

Coding

Keybinding Spacemacs Keybinding Description IntelliJ IDEA
C-, Auto-complete at point M-SPC
C-x C-i SPC s j List definitions in file and jump M-F12
C-c p c SPC c C Run compile on project
C-c p P Run tests on project
C-c p t SPC p a Toggle between implementation and test file

Code Navigation

Spacemacs Keybinding Description
( and ) Jump to beginning/end of paragraph
{ and } Jump to previous/next empty line
[[ Jump to previous } in column 0
]] Jump to next } in column 0

Smartparens

Using base keybindings for paredit. Smartparens annoyingly hijacks various emacs keybindings in a way I don't like (e.g. M-DEL for kill word backwards)

Smartparens Navigation

Keybinding Spacemacs Keybinding Description Notes
C-M-b Move backward one s-expression Must be on a paren, otherwise behaves like backward word
C-M-f Move forward one s-expression Must be on a paren, otherwise behaves like forward word
C-M-d Move down to next nested s-expression
C-M-n Move up s-expression
C-M-u Move up one level in nested s-expression Requires fix for OSX interception of the keybinding (see http://emacs.stackexchange.com/a/20544/11397)

Smartparens Editing

Keybinding Spacemacs Keybinding Description Notes
( Wrap currently selected region with parens Use with expand-region
M-s Remove parens immediately surrounding cursor point
C-(,C-{ Pull in or out previous word/s-expression into current s-expression
C-),C-} Pull in or out next word/s-expression into current s-expression
M-<up> Remove all chars before cursor point inside s-expression and surrounding parens
M-<down> Remove all chars after cursor point inside s-expression and surrounding parens
M-r Remove all chars around cursor point inside s-expression and surrounding parens
M-S Split current s-expression into two separate ones with cursor as split point
C-M-t When cursor is placed between s-expressions, swaps (transposes) their positions

Clojure

Keybinding Spacemacs Keybinding Description Notes
C-c RET clj refactor prefix See commands
M-x clojure-cheatsheet Clojure command cheatsheet

CIDER

Keybinding Spacemacs Keybinding Description Notes
C-c M-j Cider jack-in, opens nREPL in a clojure project
C-c C-k Load (eval) the current buffer
C-c C-e Eval form before current cursor position
C-c C-v v Eval form around current cursor position
C-c C-v r Eval the region and display result in echo area
C-c C-v n Eval the entire current namespace
C-c C-z Switch the REPL buffer
C-c M-z Load (eval) the current buffer and switch to the REPL buffer
C-c M-n Switch the namespace of the REPL buffer to the namespace of the current buffer
C-c C-x Reload all modified files on the classpath
C-c C-t n Run tests in current ns
C-c C-t t Run a test at the cursor position
C-u C-M-x Start debug session
C-c C-d d Display doc string for the symbol at point
C-c C-. Jump to some namespace on the classpath
, Once repl is open, get command keybindings
C-c C-q Quit current REPL session

Version Control (Magit)

Keybinding Spacemacs Keybinding Description
C-x m SPC g s See current git status/changed files
g Reload status buffer
c c, <write message>, C-c C-c c c, <write message>, C-c C-c Commit file
P u P u Push changes to remote
F u F u Pull latest changes
s Stage file
u Unstage file
b b Switch branch
navigate to file, then TAB Version diff
k revert changes
l l Show log
b Switch to branch
B Create a new branch
z Stash changes
A Unstash changes
I Exclude file(s)
M-x magit-clone Clone a repo
q q Quit

Eshell

Keybinding Spacemacs Keybinding Description
C-z Open eshell
M-p Go back in command history
M-n Go forward in command history
C-c C-r Clear the shell buffer
M-r search backwars in command history with regex
M-s search forward in command history with regex
!! Repeats the last command
!ls Repeats the last commnd starting with ls

Org mode

TODO Lists

Keybinding Spacemacs Keybinding Description
C-c C-p Move up a heading
C-c C-n Move down a heading
C-c C-b Move up a heading, same level
C-c C-f Move down a heading, same level
TAB Toggle heading open/closed states
S-TAB Toggle entire buffer heading open/closed states
M-<down> Move heading down
M-<up> Move heading up
M-<left> Promote heading
M-<right> Demote heading
C-RET New heading
M-RET New list item entry
/ Search inside org mode
C-c - Cycle item type
S-, S- Cycle state of TODO item

Table Editing

Keybinding Spacemacs Keybinding Description
C-c | Convert active region into a table
C-c C-c Re-align table
TAB SPC m t l Re-align the table and move to the next field
S-TAB SPC m t h Re-align the table and move to the previous field
| RET SPC m t i c Insert new column to the right
RET RET Re-align the table and move to the next row
C-c SPC SPC m t b Blank the table cell at cursor
C-c - SPC m t i h Insert a horizontal rule on next line
M-<left> SPC m t H Move column at cursor to the left
M-<right> SPC m t L Move column at cursor to the right
M-S-<left> SPC m t d c kill current column
M-S-<right> SPC m t i c Insert a new column to the left of the cursor
M-S-<up> SPC m t d r Kill the current table row
M-S-<down> SPC m t i r Insert new row above current row

Help

Keybinding Spacemacs Keybinding Description Notes
M-x describe-key SPC h d k Tell which function is bound to key combo
C-h b SPC ? All active keybindings with flx-ido narrowing Custom keybinding
C-h a <topics> RET Search help system for matches to
type key prefix and wait 1 sec type key prefix and wait 1 sec Get remaining completion options via which-key
C-h m Display documentation of the current major mode
C-h f Run help-apropos, an interactive version of apropos-command

Workgroups

Keybinding Spacemacs Keybinding Description Notes
C-c z C-s Save current session for workgroup
C-c z C-f Load a session for a given workgroup
C-c z c Create a new workgroup
C-c z v Switch to a workgroup

Markdown

Reference: http://ddloeffler.blogspot.ca/2013/04/keybindings-for-emacs-markdown-mode.html

Keybinding Spacemacs Keybinding Description Notes
C-c C-t h Create heading
C-c C-a l Create link
C-c C-a L Create anchor link
C-c C-s e Italisize selection/region
C-c C-s s Bold selection/region
C-c - Horizontal rule

Minibuffer

Keybindings for use inside the minibuffer.

Keybinding Spacemacs Keybinding Description Notes
TAB Auto-complete as much as possible
SPACE Complete up to one word
RET Complete and execute
? Show completion possibilities
M-r Regex search backward through command history
M-s Regex search forward through command history
C-g or Esc Esc Esc fd Abort current command

Miscellaneous

Keybinding Spacemacs Keybinding Description Notes
M-x ediff Diff Files
C-x v = View diff of current file
M-x procd View processes (like top) OR C-x p (with global keybinding)
C-x d File browser (dired)
C-x g Search in Web hooks custom binding
C-c u View URL
C-x C-f /remotehost:filename RET TRAMP remote file editing Open a directory to get a Dired buffer!
M-$ Check and fix spelling at cursor

Credits

About

A handy list of essential key bindings to commands in Emacs

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published