Function: avy-transpose-lines-in-region

avy-transpose-lines-in-region is an interactive and natively compiled function defined in avy.el.

Signature

(avy-transpose-lines-in-region)

Documentation

Transpose lines in the active region.

Key Bindings

This command is not in any keymaps.

Source Code

;; Defined in /nix/store/015952xhg9b72ira1qyjvb30bn11jiv3-emacs-packages-deps/share/emacs/site-lisp/elpa/avy-20241101.1357/avy.el
;;;###autoload
(defun avy-transpose-lines-in-region ()
  "Transpose lines in the active region."
  (interactive)
  (when (and (use-region-p) (> (count-lines (region-beginning) (region-end)) 1))
    (let ((avy-all-windows nil)
          (fst-line-point (avy--line nil (region-beginning) (region-end))))
      (when fst-line-point
        (let ((snd-line-point (avy--line nil (region-beginning) (region-end))))
          (when snd-line-point
            (save-mark-and-excursion
              (push-mark fst-line-point)
              (goto-char snd-line-point)
              (transpose-lines 0))
            (avy-transpose-lines-in-region)))))))