Do you find yourself often running a yank or undo immediately after killing lines? Would you like to copy a line instead of killing it? Do you wish that there was a prefix argument to
kill-line) that made it copy instead of cut (to use the non-Emacs terminology). Here is your solution—a command that acts just like kill-line except that it is a copy.
(defun copy-line (&optional arg) "Do a kill-line but copy rather than kill. This function directly calls kill-line, so see documentation of kill-line for how to use it including prefix argument and relevant variables. This function works by temporarily making the buffer read-only, so I suggest setting kill-read-only-ok to t." (interactive "P") (toggle-read-only 1) (kill-line arg) (toggle-read-only 0)) (setq-default kill-read-only-ok t) (global-set-key "\C-c\C-k" 'copy-line)