Skip to content

Instantly share code, notes, and snippets.

@RishiSadhir
Last active January 8, 2018 16:44
Show Gist options
  • Save RishiSadhir/7848741 to your computer and use it in GitHub Desktop.
Save RishiSadhir/7848741 to your computer and use it in GitHub Desktop.
Quick emacs function to copy the current line.
(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")))
;; optional key binding
(global-set-key "\C-c\C-k" 'copy-line)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment