C-w. You want to copy the text to the
kill-ring, not kill it. Trying to kill the text raises an error in a read-only buffer. Copying the text does not modify the buffer.
C-h k M-w tells you:
M-w runs the command
kill-ring-save (found in
global-map), which is an
interactive compiled Lisp function in
It is bound to
(kill-ring-save BEG END &optional REGION)
Save the region as if killed, but don’t kill it.
In Transient Mark mode, deactivate the mark.
interprogram-cut-function is non-
nil, also save the text for a window
system cut and paste.
If you want to append the killed line to the last killed text,
The copied text is filtered by
filter-buffer-substring before it is
saved in the kill ring, so the actual saved text might be different
from what was in the buffer.
When called from Lisp, save in the kill ring the stretch of text
END, unless the optional argument
non-nil, in which case ignore
END, and save the current
This command is similar to
copy-region-as-kill, except that it gives
visual feedback indicating the extent of the region being copied.