Emacs - Copy Line

To get the equivalent of kill line command in emacs for copying purposes, I use the following code snippet. Just copy paste it in your .emacs file. (defun copy-line (arg) "Copy lines (as many as prefix argument) in the kill ring" (interactive "p") (kill-ring-save (line-beginning-position) (line-beginning-position (+ 1 arg))) (message "%d line%s copied" arg (if (= 1 arg) "" "s"))) (global-set-key "\\M-k" 'copy-line) If \C is your control key then \M is your alt key. So generally by default your kill line can be done by \C-k Now you can also copy a line by doing: \M-k I don’t remember where I got this bit of code from, I lost those tabs when Firefox crashed. ...

October 2, 2012 · 1 min · 130 words