[Top][All Lists]

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

Re: copy-line

From: Andy Stewart
Subject: Re: copy-line
Date: Sun, 01 Feb 2009 10:09:26 +0800
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/23.0.60 (gnu/linux)


Below are my code:

------------------------------> Code start <------------------------------
(defun duplicate-line-above (&optional reverse)
  "Duplicate current line above."
  (let ((origianl-column (current-column))
    (setq line-content (buffer-substring (line-beginning-position) 
    (and reverse (forward-line +1))
    (newline +1)
    (forward-line -1)
    (insert line-content)
    (goto-column origianl-column)))

(defun duplicate-line-below ()
  "Duplicate current line below"
  (duplicate-line-above t))

(defun duplicate-line-above-comment (&optional reverse)
  "Duplicate current line above, and comment current line."
  (if reverse
    (if reverse
        (forward-line -1)
      (forward-line +1))

(defun duplicate-line-below-comment ()
  "Duplicate current line below, and comment current line."
  (duplicate-line-above-comment t))
------------------------------> Code end   <------------------------------

You can find those code at

Below are my keybing for those command:

------------------------------> keybinding start <------------------------------
("C-S-o" . duplicate-line-above)
("C-S-l" . duplicate-line-below)
("C-S-s-o" . duplicate-line-above-comment)
("C-S-s-l" . duplicate-line-below-comment)
------------------------------> keybinding end   <------------------------------


  -- Andy

Helmut Eller <address@hidden> writes:

> Hello,
> is there a command (and standard key) to copy the current line?  The
> command should duplicate the text of the current line and move point to
> the copied line.  I think that vi has something like that, and
> occasionally it would be quite useful.
> I can write that myself but maybe Emacs has something already and I
> don't know it?  It's also a bit hard to find a free key :-)
> Helmut.

reply via email to

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