5

I want to use Mac CMD+C for copy and CMD+V for paste in Spacemacs but I think it redefined CMD to Meta. How do I change this mapping behavior?

I found mac-key-mode but that package seems old and I don't know how to add it to Spacemacs.

1 Answer 1

9

Spacemacs has a "layer" called "osx" that should do everything you want.

https://github.com/syl20bnr/spacemacs/tree/master/layers/%2Bos/osx

Just put osx in the dotspacemacs-configuration-layers section and you should be all set.

If instead you just want to have some particular os x keybindings, you might find the ones below helpful:

  (let ((is-mac (string-equal system-type "darwin")))
(when is-mac
  ;; make fonts look better with anti-aliasing
  (setq mac-allow-anti-aliasing t)
  ;; delete files by moving them to the trash
  (setq delete-by-moving-to-trash t)
  (setq trash-directory "~/.Trash")

  ;; Don't make new frames when opening a new file with Emacs
  (setq ns-pop-up-frames nil)

  ;; non-lion fullscreen
  (setq ns-use-native-fullscreen nil)

  ;; Set modifier keys
  (setq mac-option-modifier 'meta) ;; Bind meta to ALT
  (setq mac-command-modifier 'super) ;; Bind apple/command to super if you want
  (setq mac-function-modifier 'hyper) ;; Bind function key to hyper if you want 
  (setq mac-right-option-modifier 'none) ;; unbind right key for accented input

  ;; Make forward delete work 
  (global-set-key (kbd "<H-backspace>") 'delete-forward-char)

  ;; Keybindings
  (global-set-key (kbd "s-=") 'scale-up-font)
  (global-set-key (kbd "s--") 'scale-down-font)
  (global-set-key (kbd "s-0") 'reset-font-size)
  (global-set-key (kbd "s-q") 'save-buffers-kill-terminal)
  (global-set-key (kbd "s-v") 'yank)
  (global-set-key (kbd "s-c") 'evil-yank)
  (global-set-key (kbd "s-a") 'mark-whole-buffer)
  (global-set-key (kbd "s-x") 'kill-region)
  (global-set-key (kbd "s-w") 'delete-window)
  (global-set-key (kbd "s-W") 'delete-frame)
  (global-set-key (kbd "s-n") 'make-frame)
  (global-set-key (kbd "s-z") 'undo-tree-undo)
  (global-set-key (kbd "s-s")
                  (lambda ()
                    (interactive)
                    (call-interactively (key-binding "\C-x\C-s"))))
  (global-set-key (kbd "s-Z") 'undo-tree-redo)
  (global-set-key (kbd "C-s-f") 'toggle-frame-fullscreen)
  ;; Emacs sometimes registers C-s-f as this weird keycode
  (global-set-key (kbd "<C-s-268632070>") 'toggle-frame-fullscreen)

))

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.