Clone a line of text in Emacs
April 24th, 2007
In order to create a key-stroke that clones a line of text in Emacs, put this in your .emacs file:
(defun duplicate-line ()
"Clones the current line of text."
(interactive)
(save-excursion
(copy-region-as-kill (line-beginning-position) (line-end-position))
(end-of-line)
(newline)
(yank)
(current-kill 1)))
(global-set-key "C-z" 'duplicate-line)
As you can see, the duplicate-line function is bound to Ctl-z - rebind to something else if needed.