Duplicate a line in emacs

When coding you often have to duplicate a line. This is a little script for your .emacs file to do this:

;; Duplicate it
(defun duplicate()
"Duplicate it."
(interactive)
(let (
(beg (line-beginning-position))
(end (line-end-position)))
(copy-region-as-kill beg end)
(beginning-of-line)
(forward-line 1)
(yank)
(newline)
(forward-line -1)))

2 comments:

drhodes said...

thanks, very useful for proofs

Anonymous said...

what is key-binding for this duplication?