Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

select a line to move it with emacs

Tags:

emacs

textmate

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?

like image 847
prosseek Avatar asked Oct 04 '10 14:10

prosseek


People also ask

How do I move a line in Emacs?

Commands to move about the screen (can also use the arrow keys.) To go to a specific line: Type M-x goto-line <Enter>, then type the line number followed by <Enter>. There are also shortcuts. Type the command "help -q emacs goto" in a local window to find out about it.

How do I move text in Emacs?

The default bindings are M-up-arrow and M-down-arrow. It works like Eclipse's (same binding) and NetBeans M-S-up/down.

How do you copy an entire line in Emacs?

Standard EmacsTriple-click 'mouse-1' somewhere on the line. Click 'mouse-1' at the the start of the line, then click 'mouse-3' at the start of the next or previous line.

What is a move line?

Moving lines means to remove them from their original place and put them in another. For instance, if you have a table that appears in one part of a file, and you want to remove the table from that part of the file and put it in another part, you would move (not copy) it.


1 Answers

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.

like image 175
ocodo Avatar answered Oct 21 '22 08:10

ocodo