Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Emacs query-replace with newlines [duplicate]

Tags:

emacs

I have the a string like this (separtred by asterisk) :

abc*dddd*fffff*

i need to replace the * with a newline. i.e the result should be:

abc
dddd
fffff

How can I do this in Emacs? I tried query-replace but pressing enter doesn't do what I want.

like image 221
AKM Avatar asked Feb 01 '11 11:02

AKM


2 Answers

Do quote the enter key: C-q C-j. There, C-q inserts the next key literally and C-j gives newline.

like image 177
maxelost Avatar answered Oct 29 '22 17:10

maxelost


Try query-replace   enter   *   enter   M-j   enter    !   enter

like image 28
sbaker Avatar answered Oct 29 '22 18:10

sbaker