|
From: | Emanuel Berg |
Subject: | Re: Keybinding to transpose current line with next line |
Date: | Thu, 24 Sep 2020 01:41:36 +0200 |
User-agent: | Gnus/5.13 (Gnus v5.13) Emacs/26.1 (gnu/linux) |
> set up [...] aliases as fit... Sure! (defun move-line (&optional lines) (interactive "*p") (let ((lin (line-number-at-pos)) (col (current-column)) (num-lines (or lines 1)) ) (beginning-of-line) (let ((line (thing-at-point 'line))) (delete-region (point-at-bol) (point-at-eol)) (delete-char 1) (goto-char (point-min)) (forward-line (+ lin num-lines -1)) (insert line) (forward-line -1) (beginning-of-line) (forward-char col) ))) (defalias 'ml #'move-line) (defalias 'mlb (lambda () (interactive) (move-line -1))) I.e.,: Forward 1: M-x ml RET Backward 1: M-x mlb RET Forward X: C-u X ml RET Backward X: C-u -X ml RET Also the usual: Forward 4: C-u ml RET Forward 16: C-u C-u ml RET etc -- underground experts united http://user.it.uu.se/~embe8573 https://dataswamp.org/~incal
[Prev in Thread] | Current Thread | [Next in Thread] |