I like the TextMate that can select a line to move it with a simple keystroke.
Command-shift L (select a line) Control-Command Arrow(up and down) (move the selected line)
How can I do the same thing with emacs?
SO user, Sanityinc developed move-text.el
(an extract of from basic-edit-toolkit.el - by emakswiki regular, Andy Stewart (lazycat))
See: Move line/region up and down in emacs
It does this task very nicely...
M-Up or M-Down to move the current line (or marked region's whole lines.)
I've added it to http://www.emacswiki.org/emacs/MoveText
Edit the bindings at the bottom to suit your preference.
I just delete the line, then yank it back in the new location. C-a C-k C-k (move to new location) C-y
move-line does that, except for the highlighting, which should be reasonably easy to add.
The standard command C-x C-t is bound to transpose-lines
. This is useful for transporting lines via interchange in a few ways.
The most obvious is that exchanges the line the point is in with the previous line.
With an argument of 0 (i.e. M-0 C-x C-t), it swaps the line that has the mark in it with the line that has the point in it.
bbatsov's prelude (a kind of Emacs starter kit) includes this functionality (see this section of code):
(defun prelude-move-line-up ()
"Move the current line up."
(interactive)
(transpose-lines 1)
(forward-line -2)
(indent-according-to-mode))
and binds it to M-S-up and M-S-down.