Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to replace a search with multiple lines in emacs?

Tags:

emacs

how to replace a match with multiple lines in emacs.

Example:- replacing "Dog" with barking animal

as shown below

The Dog 

with

The Barking
animal

I tried \n in the command replace-regexp, for which emacs throws error saying Invalid use of `\' in replacement text

like image 965
Talespin_Kit Avatar asked Dec 06 '22 20:12

Talespin_Kit


1 Answers

As documented in this article, the answer is to use C-qC-j to enter your newline if you're using M-x replace-string

So for you:

M-x replace-string RET Dog RET Barking C-qC-j animal RET

like image 76
Richard Campbell Avatar answered Dec 25 '22 06:12

Richard Campbell