MoveLineRegion

These, in combination with MoveLine and MoveRegion, provide behavior similar to Eclipse’s Alt-Up/Down. They use MoveLine if there is no active region, MoveRegion if there is. Note that unlike in Eclipse, the region will not expand to the beginning of the first line or the end of the last line, see the move-lines package for this.

(defun move-line-region-up (&optional start end n)
  (interactive "r\np")
  (if (use-region-p) (move-region-up start end n) (move-line-up n)))

(defun move-line-region-down (&optional start end n)
  (interactive "r\np")
  (if (use-region-p) (move-region-down start end n) (move-line-down n)))

(global-set-key (kbd "M-p") 'move-line-region-up)
(global-set-key (kbd "M-n") 'move-line-region-down)

CategoryEditing CategoryRegion