Reputation: 14270
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 :)
Upvotes: 4
Views: 1123
Reputation: 1391
The above answers are correct. An additional caveat: when trying match a whole line including newline, e.g. ^.*SOMETHING.*$
, replace the $
with C-q C-j, do not append C-q C-j. Unlike some other Regexp dialects, $
plus newline (C-q C-j) does not match in emacs Regexp.
Upvotes: 0
Reputation: 216
instead of \n, use C-q C-j
http://jeremy.zawodny.com/blog/archives/008872.html
Upvotes: 5
Reputation: 1288
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
.
Upvotes: 8