Say I have split my main Emacs Window into 2 :
My cursor is currently in
LEFT. How do I copy some text from
RIGHT without going to the
Here is another opinionated implementation, it assumes 2 windows layout and isn't as sophisticated as
append-to-buffer, the point is Emacs is very easy to extend.
(defun my-copy-to-next-window (b e) "Copy text in the region to next window." (interactive "r") (pcase (window-list) (`(,w0 ,w1) (with-selected-window w1 (insert-buffer-substring (window-buffer w0) b e))) (t (user-error "Only works with 2 windows"))))
There are a few relevant commands, though they are not bound to any keys by default. Try
M-x append-to-buffer to copy the region in the current buffer to another buffer.
See Accumulating-Text in the Emacs manual for details. Note these commands prompt for the target buffer. If you do this a lot with two windows open you could define your own command to look for the other visible buffer and call
append-to-buffer with that.
Unless this is something you do a lot, I think the simplest solution is to record a macro for copying to the other window.
C-x ( to start recording, then
M-w C-x o C-y C-u - C-x o to do the copying and come back, and
C-x ) to stop recording. Then press
C-x e each time you want to copy something.
You may want to tweak the macro to leave the cursor in the other buffer or to move it in a certain way. The point is that you record whatever repetitive action you want, then press a single key to perform it again.
See the manual for more information, including how to work with more than one macro, how to bind a macro to a key and how to save macros.
One indirect approach came to my mind. This can be done using
ediff-buffers. When we run this command, it puts 2 buffers in vertically split windows. Then, using
p keys, you can go to the next and previous difference. Then, by pressing
b, you can copy-paste difference from one buffer to the other.