Macos – How to cut and paste between different files using emacs

copy/pasteemacsmacos

I'm running OSX 10.6.8. Lets say I have two terminal windows open and in each window I begin editing a different file using emacs. In the first file I select some text and then copy it (M-w), and in the second file I then try and paste it (C-y). I thought this would paste what I copied from the other file but instead I get the error message "previous command was not a yank".

Those commands work just fine for copying and pasting within a single file, how do I copy and paste between different files?

Best Answer

As far as I know, emacs has no idea that a completely different instance of emacs is running in a separate Terminal.app window. You need to use the Mac's Cmd-C and Cmd-V.

I could be wrong, perhaps emacs can be set up to use some form of IPC to find other separate running instances of emacs and try to share things like clipboards between them, but that seems unusual.See @IvanAndrus' Answer for how to use emacsclient to have emacs instances work together.

If you want emacs in separate GUI windows, you might also look at Aquamacs.

Updated to add: You could also learn to use emacs' native ability to edit multiple files/buffers within the same instance: http://www.gnu.org/software/emacs/manual/html_node/emacs/Buffers.html

Related Question