0

You are likely to want to do things to the text that you just yanks / pasted (wrap it in brackets etc).

Is there a way to know what you just yanked? If so I would quite like select it (put the mark at its beginning and the point at it's end).

The obvious things that come to mind are advice for the yank functions.... but I'm hoping that there are some magic variables for this.

  • 1
    Whatever you yank gets automatically in region, so you don't need to do anything, just use that region right after a yank. – DoMiNeLa10 Oct 30 '17 at 16:12
  • Awesome - yep that works. I used to using a visual mark in evil mode... which doesn't show up after paste. For future readers (region-beginning) and (region-end) give you the yanked region after a yank. – Att Righ Oct 30 '17 at 16:36
1

The text that will yank C-y can be accessed through the kill-ring variable. Try execute that code on *scratch* buffer what you'll understand what I mean:

(mapcar 'insert kill-ring)

If you only want get the last kill-ring element you can get the text that way:

(substring-no-properties (car kill-ring))

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.