0

I often find myself wanting to exchange some text object with whatever's currently in CLIPBOARD (not necessarily in Emacs' kill-ring, when I copy from other programs). But of course when I do something like dib, it puts what I removed in the CLIPBOARD, overwriting what was in CLIPBOARD (since I didn't first paste it into Emacs), so I can't just P M-y. So I have to copy it again, next time carefully doing PudibP M-y.

This feels inefficient. Is there a built-in way in emacs/evil to, instead of deleting, exchanging what I'm removing with what's in CLIPBOARD/top-of-kill-ring?

  • Did you try C-p or C-n in normal state after pasting the text? – wasamasa Jun 5 '17 at 8:26
  • If I understand you correctly, that doesn't help, since by that time the CLIPBOARD is already overwritten. Ie. if I've copied cheese from a different program (so cheese is in CLIPBOARD but not kill-ring), and point is within (cake) and I do dibP^P, the dib will put cake in kill-ring & CLIPBOARD, overwriting cheese in the CLIPBOARD, while ^P will move back to whatever I last copied inside Emacs. – unhammer Jun 6 '17 at 7:34
  • Well, it works for me in the case that I pasted something and notice that I actually wanted to paste the earlier thing. Theory is one thing, whether it works for you is another one. – wasamasa Jun 6 '17 at 13:40
  • Your Emacs puts everything you copy from other programs into kill-ring, even if you never pasted it into Emacs? Is there a setting to make it watch the CLIPBOARD like that? – unhammer Jun 7 '17 at 7:00
  • 1
    My bad, it's a matter of (setq save-interprogram-paste-before-kill t). – wasamasa Jun 10 '17 at 14:14
1

Evil provides C-p and C-n to exchange the currently pasted item with the previous or next kill ring item. When combined with (setq save-interprogram-paste-before-kill t) whatever has been in the X clipboard will be saved to the kill ring before a kill operation, thereby becoming retrievable with C-p.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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