help-gnu-emacs
[Top][All Lists]
Advanced

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

Re: Keybinding to transpose current line with next line


From: Yuri Khan
Subject: Re: Keybinding to transpose current line with next line
Date: Tue, 22 Sep 2020 21:53:47 +0700

On Tue, 22 Sep 2020 at 21:33, Christopher Dimech <dimech@gmx.com> wrote:

> I have written the following keybinding to swap lines. If I have
> the cursor on one line, the command swaps the current line with
> the previous line.   What can I do for the keybinding to swap
> the current line with the next line, rather than with the previous one.
>
>   (global-set-key (kbd "C-t l")   'transpose-lines)

Firstly, ‘transpose-lines’ is already bound to C-x C-t.

Secondly, transposing lines is a useful low-level primitive, but IMO a
much more handy UI metaphor is dragging the line at point up or down
through the surrounding lines while preserving the point’s position in
the line. That is implemented in ‘org-drag-line-forward’ and
‘org-drag-line-backward’. Pretty much nothing in their implementations
depends on org-mode, so they can be bound and used in any mode.



reply via email to

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