[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: keybinding to duplicate the current line.

From: Ken Hori
Subject: Re: keybinding to duplicate the current line.
Date: Sun, 17 Jan 2010 06:42:56 -0800

Mine's with a region.

(defun comment-and-duplicate-region (start end)
  (interactive "r")
  (let ((s (buffer-substring start end)))
    (comment-region start end)
    (save-excursion (insert s))))

On Sun, Jan 17, 2010 at 6:37 AM, Dirk-Jan C. Binnema <address@hidden> wrote:

>>>>> "alin" == alin s <address@hidden> writes:

   alin> For me it would be very convenient to have a key-binding to duplicate the
   alin> current line.

   alin> In order to duplicate it I have to press

   alin> C-a C-SPACE C-e C-f M-w C-g C-y

   alin> It's too much for an usual function. C-x C-a would be good?

I like 'slick copy', ie., copy without needing to select:

Then, you can duplicate lines with:

 M-w C-y

Which is very natural.

   alin> More than that, if I press C-u C-x C-a, I wish to duplicate the current
   alin> line, and to comment the old line.

   alin> Do you consider that such a function would be useful for many of you?
   alin> Otherwise, I have to wtite it myseld in my own .emacs...

Something quick and fairly dirty:

(defun comment-and-dup ()
   (forward-line 1)
   (let ((str (buffer-substring (region-beginning) (region-end))))
     (comment-region (region-beginning) (region-end))
     (insert-string str))))

Best wishes,

Dirk-Jan C. Binnema                  Helsinki, Finland
e:address@hidden           w:www.djcbsoftware.nl
pgp: D09C E664 897D 7D39 5047 A178 E96A C7A1 017D DA3C

reply via email to

[Prev in Thread] Current Thread [Next in Thread]