SlideShare a Scribd company logo
Emacs Key Bindings
Kazuki Yoshida
May 15, 2018
1 / 11
References
▶ Mastering Emacs https://www.masteringemacs.org/article/
mastering-key-bindings-emacs
▶ Emacs Lisp Manual https://www.gnu.org/software/emacs/
manual/html_node/elisp/Keymaps.html#Keymaps
▶ use-package https://github.com/jwiegley/use-package
▶ bind-key https://github.com/jwiegley/use-package/blob/
master/bind-key.el
2 / 11
Basics I
▶ I use the string representation. link
▶ Modifiers: C control, M meta, S shift,
▶ Additional Modifiers (GUI only): A alt, s super, H hyper
▶ macOS configuration example
(when (eq system-type ’darwin)
;; Mac-only
;; http://www.emacswiki.org/emacs/MetaKeyProblems#toc15
;; http://ergoemacs.org/emacs/emacs_hyper_super_keys.html
(setq mac-command-modifier ’meta) ; left command
(setq mac-option-modifier ’alt) ; left option
(setq mac-right-command-modifier ’super) ; right command
(setq mac-right-option-modifier ’hyper)) ; right option
▶ Examples
3 / 11
Basics II
"C-n" ; control and n
"C-x C-f" ; control and x, then f while keeping Control down
"C-M-s" ; control, meta, and s
"s-s" ; super and s
▶ "If the binding of a key sequence is a keymap, we call the key sequence a
prefix key." link
▶ For example, C-x is a prefix that is bound to ctl-x-map. link
▶ "Otherwise, we call it a complete key." link A complete key sequence calls a
command (interactive function).
▶ "Each keymap is a list whose car is the symbol keymap. The remaining
elements of the list define the key bindings of the keymap." link A keymap
can be examined in ielm. A typical element is a pair of an ascii code (M-x
man RET ascii RET link) and command name.
4 / 11
Basics III
my-key-map ; =>
(keymap
(103 . my-magit-status)
(46 . highlight-symbol)
(122 . helm-for-files)
(114 . reveal-in-osx-finder)
(115 . shell)
(118 . revert-buffer)
(111 . just-one-space)
(108 . my-recenter-top)
(104 . help-command)
(97 . auto-revert-mode)
(107 . kill-this-buffer))
▶ Multiple keymaps are active. In descending order of priority, they are minor
mode keymaps, local keymaps (typically major mode keymaps), and global
keymaps. link
5 / 11
Basics IV
▶ To invoke alt, super, or hyper in the terminal. C-x @ can be used. For
example, C-x @ h is similar to pressing down the hyper key. link I
simplified these as follows.
(bind-key "C-c a" ’event-apply-alt-modifier function-key-map)
(bind-key "C-c s" ’event-apply-super-modifier function-key-map)
(bind-key "C-c h" ’event-apply-hyper-modifier function-key-map)
6 / 11
bind-key I
▶ "A simple way to manage personal keybindings" link
;; Macro Signature
(bind-key KEY-NAME COMMAND &optional KEYMAP PREDICATE)
;; Examples
(bind-key "A-k" ’kill-this-buffer)
(bind-key "k" ’kill-this-buffer my-key-map)
▶ bind-key* creates a global binding that overrides all minor mode
bindings.
▶ Unbinding is done with unbind-key.
(unbind-key "C-c x" some-other-mode-map)
▶ The bind-keys (plural) can be use to add multiple bindings to a keymap.
7 / 11
bind-key II
(bind-keys :map dired-mode-map
("o" . dired-omit-mode)
("a" . some-custom-dired-function))
▶ A never-shadowed personal map can be created like this.
(bind-keys* :prefix-map my-key-map
:prefix "C-c m")
▶ M-x describe-personal-keybindings shows personal bindings. I
am experiencing a funny error with my-key-map.
▶ bind-key is more typically used in the context of use-package.
8 / 11
bind-key III
(use-package swiper
:bind (("s-s" . swiper-at-point)
("C-s-s" . swiper)
("C-c C-s" . swiper)
;; Add bindings to isearch-mode
:map isearch-mode-map
("s-s" . swiper-from-isearch)
("C-c C-s" . swiper-from-isearch))
:config
(defun swiper-at-point (u-arg)
(interactive "P")
(if u-arg
(swiper)
(swiper (selection-or-thing-at-point)))))
9 / 11
which-key I
▶ "Emacs package that displays available keybindings in popup" link
▶ Waiting after a prefix key will show the contents of the corresponding
keymap.
▶ M-x which-key-show-major-mode may also be useful.
(use-package which-key
:config
(setq which-key-lighter "")
(setq which-key-idle-delay 1.0)
;; Type: minibuffer, side-window, frame, and custom.
(setq which-key-popup-type ’side-window)
(setq which-key-side-window-location ’left)
(setq which-key-side-window-max-height 0.5)
(setq which-key-side-window-max-width 0.5)
(which-key-mode 1))
10 / 11
free-keys I
▶ "Show free keybindings for modkeys or prefixes" link
;;; free-keys.el
;; https://github.com/Fuco1/free-keys
;; http://emacs.stackexchange.com/questions/964/show-unbound-keys
;; Use this to see what remaining keys are available.
;; Use bind-key.el describe-personal-keybindings for used keys.
(use-package free-keys
:commands (free-keys)
;;
:config
;; List of modifiers that can be used in front of keys.
(setq free-keys-modifiers ’(""
"C" "A" "M" "s" "H"
"C-M" "A-C" "C-s" "A-M")))
11 / 11

More Related Content

PDF
Search and Replacement Techniques in Emacs: avy, swiper, multiple-cursor, ag,...
PDF
Nobody knows-except-g4mm4
PDF
Cpp11 sample linux
PDF
Message in a bottle
PDF
SIMBLでCocoaアプリをパワーアップ
ODP
Отладка в GDB
PDF
Meet up symfony 16 juin 2017 - Les PSR
KEY
「Frama-Cによるソースコード検証」 (mzp)
Search and Replacement Techniques in Emacs: avy, swiper, multiple-cursor, ag,...
Nobody knows-except-g4mm4
Cpp11 sample linux
Message in a bottle
SIMBLでCocoaアプリをパワーアップ
Отладка в GDB
Meet up symfony 16 juin 2017 - Les PSR
「Frama-Cによるソースコード検証」 (mzp)

What's hot (20)

PDF
How to build the Web
PDF
Php radomize
ODP
Embedding perl
PDF
M09-Cross validating-naive-bayes
PDF
TRunner
PDF
Stop Monkeys Fall
PDF
LLVM Backend の紹介
PDF
ES6 - Level up your JavaScript Skills
PDF
M12 random forest-part01
PDF
M11 bagging loo cv
PDF
Binaries Are Not Only Output
PDF
Smolder @Silex
PDF
Hacking parse.y (RubyConf 2009)
PDF
Stupid Awesome Python Tricks
ODP
Optimizing mysql stored routines uc2010
PDF
PDF
Vim Hacks
PPTX
Memory management in cocos2d x - Le Duy Vu
PDF
Dip Your Toes in the Sea of Security (PHP MiNDS January Meetup 2016)
How to build the Web
Php radomize
Embedding perl
M09-Cross validating-naive-bayes
TRunner
Stop Monkeys Fall
LLVM Backend の紹介
ES6 - Level up your JavaScript Skills
M12 random forest-part01
M11 bagging loo cv
Binaries Are Not Only Output
Smolder @Silex
Hacking parse.y (RubyConf 2009)
Stupid Awesome Python Tricks
Optimizing mysql stored routines uc2010
Vim Hacks
Memory management in cocos2d x - Le Duy Vu
Dip Your Toes in the Sea of Security (PHP MiNDS January Meetup 2016)
Ad

Similar to Emacs Key Bindings (13)

ODP
Perfect? clojure environment
PDF
GNU Emacs Reference Card.pdf
PDF
Get the most out of your Mac OS X
PDF
Emacs talk
PPT
Emacs tutorial
RTF
Eclipse emacskeybindings 3_1
ODP
Learn Linux: Emacs
PDF
unix-editors.pdf
PDF
Emacs Cheatsheet
PDF
Congfigure python as_ide
PDF
osx keyboard shortcut easy usage
PDF
PDF
Perfect? clojure environment
GNU Emacs Reference Card.pdf
Get the most out of your Mac OS X
Emacs talk
Emacs tutorial
Eclipse emacskeybindings 3_1
Learn Linux: Emacs
unix-editors.pdf
Emacs Cheatsheet
Congfigure python as_ide
osx keyboard shortcut easy usage
Ad

More from Kazuki Yoshida (20)

PDF
Graphical explanation of causal mediation analysis
PPTX
Pharmacoepidemiology Lecture: Designing Observational CER to Emulate an RCT
PDF
What is the Expectation Maximization (EM) Algorithm?
PDF
Propensity Score Methods for Comparative Effectiveness Research with Multiple...
PDF
Visual Explanation of Ridge Regression and LASSO
PDF
ENAR 2018 Matching Weights to Simultaneously Compare Three Treatment Groups: ...
PDF
Comparison of Privacy-Protecting Analytic and Data-sharing Methods: a Simulat...
PDF
Spacemacs: emacs user's first impression
PDF
Matching Weights to Simultaneously Compare Three Treatment Groups: a Simulati...
PDF
Multiple Imputation: Joint and Conditional Modeling of Missing Data
PDF
20130222 Data structures and manipulation in R
PDF
20130215 Reading data into R
PDF
Linear regression with R 2
PDF
Linear regression with R 1
PDF
(Very) Basic graphing with R
PDF
Introduction to Deducer
PDF
Groupwise comparison of continuous data
PDF
Categorical data with R
PDF
Install and Configure R and RStudio
PDF
Reading Data into R REVISED
Graphical explanation of causal mediation analysis
Pharmacoepidemiology Lecture: Designing Observational CER to Emulate an RCT
What is the Expectation Maximization (EM) Algorithm?
Propensity Score Methods for Comparative Effectiveness Research with Multiple...
Visual Explanation of Ridge Regression and LASSO
ENAR 2018 Matching Weights to Simultaneously Compare Three Treatment Groups: ...
Comparison of Privacy-Protecting Analytic and Data-sharing Methods: a Simulat...
Spacemacs: emacs user's first impression
Matching Weights to Simultaneously Compare Three Treatment Groups: a Simulati...
Multiple Imputation: Joint and Conditional Modeling of Missing Data
20130222 Data structures and manipulation in R
20130215 Reading data into R
Linear regression with R 2
Linear regression with R 1
(Very) Basic graphing with R
Introduction to Deducer
Groupwise comparison of continuous data
Categorical data with R
Install and Configure R and RStudio
Reading Data into R REVISED

Recently uploaded (20)

PPTX
ManageIQ - Sprint 268 Review - Slide Deck
PDF
Claude Code: Everyone is a 10x Developer - A Comprehensive AI-Powered CLI Tool
PDF
top salesforce developer skills in 2025.pdf
PPTX
L1 - Introduction to python Backend.pptx
PPT
Introduction Database Management System for Course Database
PDF
Design an Analysis of Algorithms I-SECS-1021-03
PDF
Odoo Companies in India – Driving Business Transformation.pdf
PDF
Flood Susceptibility Mapping Using Image-Based 2D-CNN Deep Learnin. Overview ...
PDF
Nekopoi APK 2025 free lastest update
PDF
Upgrade and Innovation Strategies for SAP ERP Customers
PPTX
history of c programming in notes for students .pptx
PDF
Why TechBuilder is the Future of Pickup and Delivery App Development (1).pdf
PDF
How to Choose the Right IT Partner for Your Business in Malaysia
PPTX
Odoo POS Development Services by CandidRoot Solutions
PDF
Softaken Excel to vCard Converter Software.pdf
PPTX
Agentic AI Use Case- Contract Lifecycle Management (CLM).pptx
PDF
Addressing The Cult of Project Management Tools-Why Disconnected Work is Hold...
PDF
T3DD25 TYPO3 Content Blocks - Deep Dive by André Kraus
PPTX
CHAPTER 12 - CYBER SECURITY AND FUTURE SKILLS (1) (1).pptx
PDF
medical staffing services at VALiNTRY
ManageIQ - Sprint 268 Review - Slide Deck
Claude Code: Everyone is a 10x Developer - A Comprehensive AI-Powered CLI Tool
top salesforce developer skills in 2025.pdf
L1 - Introduction to python Backend.pptx
Introduction Database Management System for Course Database
Design an Analysis of Algorithms I-SECS-1021-03
Odoo Companies in India – Driving Business Transformation.pdf
Flood Susceptibility Mapping Using Image-Based 2D-CNN Deep Learnin. Overview ...
Nekopoi APK 2025 free lastest update
Upgrade and Innovation Strategies for SAP ERP Customers
history of c programming in notes for students .pptx
Why TechBuilder is the Future of Pickup and Delivery App Development (1).pdf
How to Choose the Right IT Partner for Your Business in Malaysia
Odoo POS Development Services by CandidRoot Solutions
Softaken Excel to vCard Converter Software.pdf
Agentic AI Use Case- Contract Lifecycle Management (CLM).pptx
Addressing The Cult of Project Management Tools-Why Disconnected Work is Hold...
T3DD25 TYPO3 Content Blocks - Deep Dive by André Kraus
CHAPTER 12 - CYBER SECURITY AND FUTURE SKILLS (1) (1).pptx
medical staffing services at VALiNTRY

Emacs Key Bindings

  • 1. Emacs Key Bindings Kazuki Yoshida May 15, 2018 1 / 11
  • 2. References ▶ Mastering Emacs https://www.masteringemacs.org/article/ mastering-key-bindings-emacs ▶ Emacs Lisp Manual https://www.gnu.org/software/emacs/ manual/html_node/elisp/Keymaps.html#Keymaps ▶ use-package https://github.com/jwiegley/use-package ▶ bind-key https://github.com/jwiegley/use-package/blob/ master/bind-key.el 2 / 11
  • 3. Basics I ▶ I use the string representation. link ▶ Modifiers: C control, M meta, S shift, ▶ Additional Modifiers (GUI only): A alt, s super, H hyper ▶ macOS configuration example (when (eq system-type ’darwin) ;; Mac-only ;; http://www.emacswiki.org/emacs/MetaKeyProblems#toc15 ;; http://ergoemacs.org/emacs/emacs_hyper_super_keys.html (setq mac-command-modifier ’meta) ; left command (setq mac-option-modifier ’alt) ; left option (setq mac-right-command-modifier ’super) ; right command (setq mac-right-option-modifier ’hyper)) ; right option ▶ Examples 3 / 11
  • 4. Basics II "C-n" ; control and n "C-x C-f" ; control and x, then f while keeping Control down "C-M-s" ; control, meta, and s "s-s" ; super and s ▶ "If the binding of a key sequence is a keymap, we call the key sequence a prefix key." link ▶ For example, C-x is a prefix that is bound to ctl-x-map. link ▶ "Otherwise, we call it a complete key." link A complete key sequence calls a command (interactive function). ▶ "Each keymap is a list whose car is the symbol keymap. The remaining elements of the list define the key bindings of the keymap." link A keymap can be examined in ielm. A typical element is a pair of an ascii code (M-x man RET ascii RET link) and command name. 4 / 11
  • 5. Basics III my-key-map ; => (keymap (103 . my-magit-status) (46 . highlight-symbol) (122 . helm-for-files) (114 . reveal-in-osx-finder) (115 . shell) (118 . revert-buffer) (111 . just-one-space) (108 . my-recenter-top) (104 . help-command) (97 . auto-revert-mode) (107 . kill-this-buffer)) ▶ Multiple keymaps are active. In descending order of priority, they are minor mode keymaps, local keymaps (typically major mode keymaps), and global keymaps. link 5 / 11
  • 6. Basics IV ▶ To invoke alt, super, or hyper in the terminal. C-x @ can be used. For example, C-x @ h is similar to pressing down the hyper key. link I simplified these as follows. (bind-key "C-c a" ’event-apply-alt-modifier function-key-map) (bind-key "C-c s" ’event-apply-super-modifier function-key-map) (bind-key "C-c h" ’event-apply-hyper-modifier function-key-map) 6 / 11
  • 7. bind-key I ▶ "A simple way to manage personal keybindings" link ;; Macro Signature (bind-key KEY-NAME COMMAND &optional KEYMAP PREDICATE) ;; Examples (bind-key "A-k" ’kill-this-buffer) (bind-key "k" ’kill-this-buffer my-key-map) ▶ bind-key* creates a global binding that overrides all minor mode bindings. ▶ Unbinding is done with unbind-key. (unbind-key "C-c x" some-other-mode-map) ▶ The bind-keys (plural) can be use to add multiple bindings to a keymap. 7 / 11
  • 8. bind-key II (bind-keys :map dired-mode-map ("o" . dired-omit-mode) ("a" . some-custom-dired-function)) ▶ A never-shadowed personal map can be created like this. (bind-keys* :prefix-map my-key-map :prefix "C-c m") ▶ M-x describe-personal-keybindings shows personal bindings. I am experiencing a funny error with my-key-map. ▶ bind-key is more typically used in the context of use-package. 8 / 11
  • 9. bind-key III (use-package swiper :bind (("s-s" . swiper-at-point) ("C-s-s" . swiper) ("C-c C-s" . swiper) ;; Add bindings to isearch-mode :map isearch-mode-map ("s-s" . swiper-from-isearch) ("C-c C-s" . swiper-from-isearch)) :config (defun swiper-at-point (u-arg) (interactive "P") (if u-arg (swiper) (swiper (selection-or-thing-at-point))))) 9 / 11
  • 10. which-key I ▶ "Emacs package that displays available keybindings in popup" link ▶ Waiting after a prefix key will show the contents of the corresponding keymap. ▶ M-x which-key-show-major-mode may also be useful. (use-package which-key :config (setq which-key-lighter "") (setq which-key-idle-delay 1.0) ;; Type: minibuffer, side-window, frame, and custom. (setq which-key-popup-type ’side-window) (setq which-key-side-window-location ’left) (setq which-key-side-window-max-height 0.5) (setq which-key-side-window-max-width 0.5) (which-key-mode 1)) 10 / 11
  • 11. free-keys I ▶ "Show free keybindings for modkeys or prefixes" link ;;; free-keys.el ;; https://github.com/Fuco1/free-keys ;; http://emacs.stackexchange.com/questions/964/show-unbound-keys ;; Use this to see what remaining keys are available. ;; Use bind-key.el describe-personal-keybindings for used keys. (use-package free-keys :commands (free-keys) ;; :config ;; List of modifiers that can be used in front of keys. (setq free-keys-modifiers ’("" "C" "A" "M" "s" "H" "C-M" "A-C" "C-s" "A-M"))) 11 / 11