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?
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?
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.
SO user, Sanityinc developed move-text.el
(an extract of from basic-edit-toolkit.el - by emakswiki regular, Andy Stewart (lazycat))
See: http://stackoverflow.com/questions/2423834/move-line-region-up-and-down-in-emacs/2426347#2426347
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.