Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

By Emacs, how to join two lines into one?

Tags:

emacs

editor

I am new to Emacs. I have googled this but no good answer there. One of them is Ctrl-n Ctrl-a Backspace This works but is stupid. Is there a quick and simple way to join a block of lines into a single line?

Actually, I can use Esc-q to auto-fill a paragraph now, but how could I get it to revert without UNDO?

like image 358
jcadam Avatar asked Jul 02 '09 05:07

jcadam


People also ask

How do I join lines in vi?

When you want to merge two lines into one, position the cursor anywhere on the first line, and press J to join the two lines. J joins the line the cursor is on with the line below. Repeat the last command ( J ) with the . to join the next line with the current line.


2 Answers

Place point anywhere on the last line of the group of lines that need joining and call

M-^ 

repeatedly until all the lines are merged.

Note: It leaves one space between all of the now joined lines.

like image 110
Ray Avatar answered Sep 17 '22 18:09

Ray


M-x join-line will join two lines. Just bind it to a convenient keystroke.

like image 45
pgs Avatar answered Sep 21 '22 18:09

pgs