Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to remove all newlines from selected region in Emacs?

How to remove all newlines from selected region in Emacs?

like image 455
Sławosz Avatar asked Mar 04 '11 13:03

Sławosz


2 Answers

  1. M-x replace-string
  2. C-q C-j
  3. RET
  4. RET

The trick is to quote the C-j with C-q, but otherwise replacing newlines is like replacing anything else.

like image 197
Bruce Stephens Avatar answered Oct 23 '22 10:10

Bruce Stephens


With my key bindings, which I think are standard, on windows:

Select region

shift-alt-%

ctrl-Q ctrl-J

return

return

!

Or to put it another way, query replace region, ctrl-q to get extended characters, ctrl-j to put in a newline, replace with nothing, all of them.

like image 37
Pete Avatar answered Oct 23 '22 09:10

Pete