Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I replace a regular expression with a newline in emacs

Tags:

regex

emacs

I would like to put a newline after every tag in an HTML file in Emacs. Now I have got

M-x query-replace-regexp \(<[^>]*>\) --> \1\n

This returns

invalid use of "\"

I've already tried C-x C-j, but that returns <html>C-x C-j<head>C-x C-j etc...

If anybody knows the solution, that would be helpful :)

like image 331
vrwim Avatar asked Oct 28 '25 10:10

vrwim


1 Answers

You can use C-q to insert control characters.

C-q C-j to insert a newline, C-q C-i to insert a tabulator etc.

So instead of \n just type C-q C-j.

like image 69
chrm Avatar answered Oct 29 '25 23:10

chrm



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!