From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Joe Fineman Newsgroups: gmane.emacs.help Subject: Re: copy-line Date: Sat, 31 Jan 2009 20:18:14 -0500 Organization: A noiseless patient Spider Message-ID: References: NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: ger.gmane.org 1233452454 15054 80.91.229.12 (1 Feb 2009 01:40:54 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sun, 1 Feb 2009 01:40:54 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Sun Feb 01 02:42:08 2009 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1LTRLY-00058C-Ui for geh-help-gnu-emacs@m.gmane.org; Sun, 01 Feb 2009 02:42:05 +0100 Original-Received: from localhost ([127.0.0.1]:56320 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1LTRKG-0003yk-E5 for geh-help-gnu-emacs@m.gmane.org; Sat, 31 Jan 2009 20:40:44 -0500 Original-Path: news.stanford.edu!headwall.stanford.edu!newsfeed.news2me.com!newsfeed.icl.net!newsfeed.fjserv.net!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!feeder.erje.net!news.motzarella.org!motzarella.org!news.motzarella.org!not-for-mail Original-Newsgroups: gnu.emacs.help Original-Lines: 35 Original-X-Trace: news.eternal-september.org U2FsdGVkX1+QLERkL2MpHyfkr0UL+zASe++4KT3SzJ0v6nedDnHxUTTmQuOCxl025R/wC35Y7zVcsd9dHSRlA92VvdPfSlPmwGQDWbFheHrn+Ef2ZJBJPjIyG1f/gyjamS2QaCdHzJU= Original-X-Complaints-To: Please send complaints to abuse@motzarella.org with full headers Original-NNTP-Posting-Date: Sun, 1 Feb 2009 01:18:18 +0000 (UTC) X-Auth-Sender: U2FsdGVkX1/IGB7W9yhpXqk6SSM0xkAnwhEost4glMI= Cancel-Lock: sha1:XjqIKafY6H2cagCDW9zB02bn13s= sha1:BuC0W5GEuws7dhC7bpXt+L2dTQc= User-Agent: Gnus/5.101 (Gnus v5.10.10) Emacs/22.3 (windows-nt) Original-Xref: news.stanford.edu gnu.emacs.help:166492 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:61813 Archived-At: Helmut Eller writes: > 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 :-) I have been using the following kluge extensively for a long time. I mainly use it in tables, but it is also useful for duplicating a line that contains no tabs: (defun ditto () "In a table, duplicate the entry above." (interactive) (let ((track-eol) (goal-column (current-column))) (skip-chars-backward "^\t\n") (setq newplace (point-marker)) (previous-line 1) (setq oldplace (point-marker)) (skip-chars-forward "^\t\n") (setq entry (buffer-substring oldplace (point))) (goto-char newplace) (skip-chars-forward "^\t\n") (delete-region newplace (point)) (set-mark (point)) (insert entry) ) ) -- --- Joe Fineman joe_f@verizon.net ||: It could have been worse -- it could have been me. :||