News for hackers. Stuff that matters.
Re:Copying Lines, not killing by randrews on Monday May 18, 2009 @08:30PM (#615998)
I had this same problem, and I solved it thusly:

  (defun duplicate-line ()
    "Duplicate the line the point is on, moving the point to the duplicate"
    (interactive)
    (save-excursion
      (kill-new (buffer-substring (line-beginning-position) (line-end-position)))
      (end-of-line)
      (newline)
      (yank)
      (rotate-yank-pointer 1))
    (next-line 1))
I'm sure there's a better way to do that (this is one of the first elisp things I ever wrote), but the general idea is that you duplicate the line the point is on, and then move the point down one line. It's surprisingly useful, more so than copying a line to the kill ring.

There are no comments on this comment yet.