0

How can I make a function that copies text from line number N at point? I will be at some specific line and point position and want to copy the text from a different line N.

Dilna
  • 1
  • 3
  • 11

1 Answers1

3
(defun foo (n)
  "Copy line N to the kill-ring.
N is the numeric prefix arg"
  (interactive "p")
  (save-excursion
    (goto-char (point-min))
    (forward-line (1- n))
    (kill-ring-save (line-beginning-position) (line-end-position))))
NickD
  • 29,717
  • 3
  • 27
  • 44
Drew
  • 77,472
  • 10
  • 114
  • 243