Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to copy text in Emacs Evil-Mode without overwriting the clipboard?

This post described how to do it in Vim, where one prefixes their copy command with " + <register name> (ie k). How can I do this in Emacs Evil-Mode?

For example, I tried the following:

  • yy - copy first line to clipboard
  • jjj - move to some new line
  • "kyy - copy second line to register k
  • Move to my new region
  • p - paste first line
  • "kp - paste second line

However, at p, Emacs pastes my second line, as if the register was ignored and copied directly to the clipboard. Any suggestions on how to use Vim-like registers? If not, any suggestions on how to copy and paste multiple regions in Evil-Mode?

like image 463
modulitos Avatar asked Oct 20 '14 18:10

modulitos


1 Answers

I think setting this value will do it:

(setq x-select-enable-clipboard nil)

Using evil (in spacemacs), "+y still copies to clipboard, so I think that should work.


If not, this blog post describes a more verbose method: Write handlers for all ways you can delete to avoid touching the clipboard and rebind keys to use these handlers.

like image 93
idbrii Avatar answered Sep 19 '22 06:09

idbrii