In Emacs, how do I copy a region of text (to paste it in another buffer) without killing it (for example: the file I want to copy from is opened in read-only mode, so killing it isn't an option).
Once you have a region selected, the most basic commands are: To cut the text, press C-w . To copy the text, press M-w . To paste the text, press C-y .
Ctrl-y - This command will yank back the text which was deleted most recently with the above command. The text will be placed at the current emacs cursor location. You can yank back the text as many times as you wish. Meta-y - When you kill or copy a region of text, it doesn't forget about previous kills.
An Emacs copy is the command kill-ring-save (usually bound to M-w ). A system copy is what you typically get from pressing C-c (or choosing "Edit->Copy" in a application window). An X copy is "physically" highlighting text with the mouse cursor. An Emacs paste is the command yank (usually bound to C-y ).
Just mark it (C-space at one end of the range, and move to the other end) and use M-w (kill-ring-save
):
(kill-ring-save BEG END)
Save the region as if killed, but don't kill it.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With