How can i yank to/from windows clipboard when using:

  • Windows 7 (x64)
  • GNU Emacs 24.4.1 (x64)
  • Evil 1.0.9
  • and having (setq x-select-enable-clipboard nil) in my .emacs? (I put this line there because i didn't want vim changes (x, d, etc) to clobber my os clipboard.

I tried "+p, "*p, "+y, "*y, CTRL+Y but it doesn't work. When i run :registers it doesn't even show + or * registers.

To clarify: I want Emacs to behave like Vim when copying/yanking to/from different registers, without clobbering os clipboard with every text changing command. In particular:

  • yy - should NOT yank text to os clipboard (only to 0 register)
  • "+yy - should yank text to os clipboard
  • dd - should NOT clobber os clipboard
  • cw - shold NOT clobber os clipboard
  • etc.

3 Answers 3


I disabled the clipboard integration with:

(setq x-select-enable-clipboard nil)

Then you should still be able to copy and paste using the + register of evil. If you still want to integrate with the clipboard without evil, you could use this function to paste:

(defun paste-from-clipboard ()
  (setq x-select-enable-clipboard t)
  (setq x-select-enable-clipboard nil))

and this one for copyping:

(defun copy-to-clipboard()
  (setq x-select-enable-clipboard t)
  (kill-ring-save (region-beginning) (region-end))
  (setq x-select-enable-clipboard nil))

Then bind copy-to-clipboard to M-w and paste-from-clipboard to C-y, or other keybinding of your choice.

Edit: I'm running Archlinux. Can't say if this'll work on Windows.

  • Under Linux Mint the (setq x-select-enable-clipboard nil) is enough too because there are + and * registers to work with os clipboard, not under windows unfortunately.
    – Kossak
    Jun 26, 2015 at 17:37
  • I tried your custom function (in windows) with evil plugin and (setq x-select-enable-clipboard nil): The yanking FROM os clipboard works as it should, but i can't yank the selection TO os clipboard (with bindings (define-key evil-normal-state-map (kbd "C-y") 'paste-from-clipboard) and (define-key evil-visual-state-map (kbd "C-y") 'paste-from-clipboard)
    – Kossak
    Jun 26, 2015 at 17:39
  • I'm not sure if I get what you mean, paste-from-clipboard will only paste from clipboard. You'll need another function to copy to clipboard. I edited the question to added a copy-to-clipboard function. Please try if it works
    – Jesse
    Jun 26, 2015 at 18:30
  • I wrongly thought the yank function copies to and from os clipboard (based on the presence of visual selection). Your other function does what i want, thank you.
    – Kossak
    Jun 27, 2015 at 8:20


it cover ALL the use cases on Mac/Linux/Windows/Cygwin.

More specifically, for copy&paste, there are only two commands:


Feel free to assign short keys.

  • This is wonderful, it simplifies interaction with the clipboard drastically.
    – loevborg
    Jan 3, 2016 at 11:11
  • Agreed that this is a wonderful little tool, and still working beautifully in 2022 (updated as recently as 2020).
    – mncz
    May 13, 2022 at 10:12

For people trying this on macOs, I used pbcopy.el. I realize this question was for Windows, but I spent a lot of time trying to get it to work on macOs, so sharing what I used.

To use your system’s clipboard on copy, cut and paste, install pbcopy

To install it, run

  1. M-x package-install
  2. Press the return key
  3. provide pbcopy.el as the package to install
  4. Press the return key
  5. inside your config file, add:
(require 'pbcopy)
  1. restart emacs

Your Answer

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

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