Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Emacs: copying text (without killing it)

Tags:

emacs

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).

like image 325
user924 Avatar asked Jul 01 '10 13:07

user924


People also ask

How do I copy text in Emacs?

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 .

How do you yank in Emacs?

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.

How do I copy from Emacs to clipboard?

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 ).


1 Answers

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.

like image 142
Michael Mrozek Avatar answered Oct 04 '22 18:10

Michael Mrozek