|
From: | Emanuel Berg |
Subject: | Re: Keybinding to transpose current line with next line |
Date: | Tue, 22 Sep 2020 22:05:59 +0200 |
User-agent: | Gnus/5.13 (Gnus v5.13) Emacs/26.1 (gnu/linux) |
Yuri Khan wrote: > 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. hm ...? You mean like this? (defun transpose-next-line () (interactive) (let ((beg (point)) (lin (line-number-at-pos) )) (beginning-of-line) (kill-line) (yank) (kill-line) (forward-line -1) (yank) (goto-char beg) (unless (= lin (line-number-at-pos)) (goto-char (point-min)) (forward-line (1- lin)) (end-of-line) ))) (defalias 'tnl #'transpose-next-line) ; [1] [1] https://dataswamp.org/~incal/emacs-init/geh.el -- underground experts united http://user.it.uu.se/~embe8573 https://dataswamp.org/~incal
[Prev in Thread] | Current Thread | [Next in Thread] |