Skip to content

Instantly share code, notes, and snippets.

@dsjt
Created June 18, 2014 11:17
Show Gist options
  • Save dsjt/58318935288e68794de7 to your computer and use it in GitHub Desktop.
Save dsjt/58318935288e68794de7 to your computer and use it in GitHub Desktop.
duplicate-line for emacs
(defun duplicate-line(arg)
(interactive "nTimes:")
(or (and (numberp arg) (> arg 0)) (setq arg 1))
(beginning-of-line)
(kill-whole-line)
(yank)
(multi-yank (- arg 1)))
(defun multi-yank(arg)
"yank [arg] times."
(interactive "p")
(or (and (numberp arg) (> arg 0)) (setq arg 1))
(if (= arg 1)
(yank)
(progn (yank)
(recur-multi-yank (- arg 1))))
(defun recur-multi-yank(arg)
(if(= arg 1)
(yank)
(progn (yank)
(recur-multi-yank (- arg 1))))))
(global-set-key (kbd "C-S-y") 'duplicate-line)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment