Skip to content

Instantly share code, notes, and snippets.

@rnkn
Last active June 30, 2016 06:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rnkn/4e5e6670f6cee36f9544 to your computer and use it in GitHub Desktop.
Save rnkn/4e5e6670f6cee36f9544 to your computer and use it in GitHub Desktop.
macOS command keys for Emacs
(when ns-window-system
(setq ns-command-modifier 'hyper)
(let ((cmd (cond ((eq ns-command-modifier 'hyper) "H-")
((eq ns-command-modifier 'super) "s-"))))
(global-set-key (kbd (concat cmd "<left>")) 'beginning-of-line)
(global-set-key (kbd (concat cmd "<right>")) 'end-of-line)
(global-set-key (kbd (concat cmd "<up>")) 'beginning-of-buffer)
(global-set-key (kbd (concat cmd "<down>")) 'end-of-buffer)
(global-set-key (kbd (concat cmd "o")) 'find-file-existing)
(global-set-key (kbd (concat cmd "n")) 'make-frame)
(global-set-key (kbd (concat cmd "s")) 'save-buffer)
(global-set-key (kbd (concat cmd "S")) 'write-file)
(global-set-key (kbd (concat cmd "a")) 'mark-whole-buffer)
(global-set-key (kbd (concat cmd "z")) 'undo)
(global-set-key (kbd (concat cmd "Z")) 'redo)
(global-set-key (kbd (concat cmd "l")) 'goto-line)
(global-set-key (kbd (concat cmd "x")) 'kill-region)
(global-set-key (kbd (concat cmd "c")) 'kill-ring-save)
(global-set-key (kbd (concat cmd "v")) 'yank)
(global-set-key (kbd (concat cmd "`")) 'other-frame)
(global-set-key (kbd (concat cmd "q")) 'save-buffers-kill-terminal)
(global-set-key (kbd (concat cmd "w")) 'delete-frame)
(global-set-key (kbd (concat cmd "f")) 'isearch-forward)
(global-set-key (kbd (concat cmd ".")) 'keyboard-quit)
(global-set-key (kbd (concat cmd "C-f")) 'toggle-frame-fullscreen)
(global-set-key (kbd (concat cmd "b")) 'list-buffers)
(global-set-key (kbd (concat cmd "1")) 'delete-other-windows)
(global-set-key (kbd (concat cmd "2")) 'split-window-below)
(global-set-key (kbd (concat cmd "3")) 'split-window-right)
(global-set-key (kbd (concat cmd "0")) 'delete-window)
(global-set-key (kbd (concat cmd "'")) 'other-window)
(global-set-key (kbd (concat cmd "=")) 'text-scale-increase)
(global-set-key (kbd (concat cmd "-")) 'text-scale-decrease)
(global-set-key (kbd (concat cmd "R")) 'reveal-in-finder)
(global-set-key (kbd (concat cmd "U")) '-revert-buffer-no-confirm)))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment