all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: "Bourgneuf Francois" <francois.bourgneuf@groupe-mma.fr>
Subject: RE: Anyone have a 'move-line' function?
Date: Thu, 4 May 2006 14:11:05 +0200	[thread overview]
Message-ID: <8A921A5AACA1A64F936C730FC1F817210F3975@zw67246c.societe.mma.fr> (raw)

I think the transpose-line command may be what you're looking for.

It is bound to C-x C-t.

Exchange current line and previous line, leaving point after both.
With argument ARG, takes previous line and moves it past ARG lines.
With argument 0, interchanges line point is in with line mark is in.

Bour9

-----Message d'origine-----
De : help-gnu-emacs-bounces+francois.bourgneuf=groupe-mma.fr@gnu.org [mailto:help-gnu-emacs-bounces+francois.bourgneuf=groupe-mma.fr@gnu.org] De la part de liyer.vijay@gmail.com
Envoyé : mercredi 3 mai 2006 23:04
À : help-gnu-emacs@gnu.org
Objet : Re: Anyone have a 'move-line' function?

Joe Smith wrote:
> If I start with this (^=point):
>
> one
> two
> th^ree
> four
>
> And I run 'move-line-up' (say by M-up), I want this:
>
> one
> th^ree
> two
> four
>
> Then run 'move-line-down' twice (say by M-down M-down) to get this:
>
> one
> two
> four
> th^ree

Here's a solution that doesn't add to the kill-ring (not that we'll
reach the kill ring limit :-)

(defun move-line-up (&optional n)
  "Moves current line up leaving point in place.  With a prefix
argument, moves up N lines."
  (interactive "p")
  (if (null n) (setq n 1))
  (let ((col (current-column)))
    (beginning-of-line)
    (next-line 1)
    (transpose-lines (- n))
    (previous-line 1)
    (forward-char col)))

Cheers
Vijay

_______________________________________________
help-gnu-emacs mailing list
help-gnu-emacs@gnu.org
http://lists.gnu.org/mailman/listinfo/help-gnu-emacs

             reply	other threads:[~2006-05-04 12:11 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-05-04 12:11 Bourgneuf Francois [this message]
     [not found] <mailman.1234.1146610060.9609.help-gnu-emacs@gnu.org>
2006-05-02 23:33 ` Anyone have a 'move-line' function? Bastien
2006-05-03  3:46   ` Joe Smith
     [not found]   ` <mailman.1250.1146628814.9609.help-gnu-emacs@gnu.org>
2006-05-03  8:17     ` Mathias Dahl
2006-05-03 21:03     ` liyer.vijay
2006-05-04 15:29       ` Joe Smith
2006-05-04 16:24         ` John Conrad
2006-05-04 20:03           ` Joe Smith
     [not found]       ` <mailman.1411.1146756636.9609.help-gnu-emacs@gnu.org>
2006-05-05  0:09         ` liyer.vijay
  -- strict thread matches above, loose matches on Subject: below --
2006-05-02 18:44 Joe Smith

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=8A921A5AACA1A64F936C730FC1F817210F3975@zw67246c.societe.mma.fr \
    --to=francois.bourgneuf@groupe-mma.fr \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.