Say we want to kill the region selected by all cursors in multiple-cursors, and yank it all to a new, empty buffer. How do you do that with multiple-cursors?

Note that a simple copy and paste of the text on the new buffer does not work, since it only yanks the region from the first cursor (as reported here).

Note: This question is motivated by the answer and problem presented in: Keeping only the lines with the cursors in multiple-cursors

2 Answers 2


Once text has been killed, exit multiple-cursor (enter) and while in new buffer hit C-x r y (normally the killed text is in the rectangle kill-ring)

  • 4
    After thousands of time failing to yank all the killed things I am frustrated to find that one MUST exit multiple-cursor to make C-x r y work. :( Jan 6, 2016 at 16:08
  • The killed text in the first time persists somehow, is there something like a "cache" that I need to clear? Thanks!
    – benjaminz
    Dec 22, 2016 at 20:43
  • 1
    I consider this solution to be ugly hack.
    – dev1223
    Jul 6, 2019 at 19:36

Try this. Just select text using multiple cursors and hit C-c. Just like in any other normal editor these days.

(setq *cutom/bulk-clipboard* nil)

(push 'custom/copy-across-cursors
(push 'cua-copy-region

(defun custom/copy-across-cursors ()
       (custom/copy-across-cursor cursor)))))
  (push (buffer-substring
         (caar (region-bounds))
         (cdar (region-bounds)))
  (kill-new (s-chomp (loop for x in *cutom/bulk-clipboard*
                           concat (concat x "\n"))))
  (setq *cutom/bulk-clipboard* nil))

(defun custom/copy-across-cursor (cursor)
  (let ((mc--executing-command-for-fake-cursor t)
        (id (overlay-get cursor 'mc-id))
        (annoying-arrows-mode nil)
        (smooth-scroll-margin 0))
     (mc/pop-state-from-overlay cursor)
       (mc/create-fake-cursor-at-point id)))))

(defun custom/cursor-handle-copy ()
  (when (region-active-p)
    (push (buffer-substring
           (caar (region-bounds))
           (cdar (region-bounds)))
  (when deactivate-mark (deactivate-mark)))

(advice-add #'cua-copy-region
            :around (lambda (oldfn &rest args)
                      (if (> (mc/num-cursors) 1)
                        (apply oldfn args))))

Please, note that dependency on library s is present. Also this code expects you use CUA mode. If not, you must customize advice definition at the bottom.

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.