Use M-w
, not 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 simple.el
.
It is bound to M-delete
, C-insertchar
, C-insert
, M-w
.
(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.
If 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,
use C-M-w
before M-w
.
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
between BEG
and END
, unless the optional argument REGION
is
non-nil, in which case ignore BEG
and END
, and save the current
region instead.
This command is similar to copy-region-as-kill
, except that it gives
visual feedback indicating the extent of the region being copied.