Function: transpose-lines

transpose-lines is an interactive and byte-compiled function defined in simple.el.gz.

Signature

(transpose-lines ARG)

Documentation

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.

Key Bindings

Source Code

;; Defined in /usr/src/emacs/lisp/simple.el.gz
(defun transpose-lines (arg)
  "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."
  (interactive "*p")
  (transpose-subr (lambda (arg)
                    (if (> arg 0)
                        (progn
                          ;; Move forward over ARG lines,
                          ;; but create newlines if necessary.
                          (setq arg (forward-line arg))
                          (if (/= (preceding-char) ?\n)
                              (setq arg (1+ arg)))
                          (if (> arg 0)
                              (newline arg)))
                      (forward-line arg)))
		  arg))