help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Using replace-regexp doesn't remove newlines?


From: ozark
Subject: Using replace-regexp doesn't remove newlines?
Date: 15 Jul 2005 05:32:43 -0700
User-agent: G2/0.2

Some of the lines in the buffer have only the single character '#' in
them. I want to remove all such lines.
I tried doing the following:

M-x replace-regexp ^#$<RET><RET>
This replaces the lines with # in them by blank lines. As this is not I
want, I undid that, and instead tried

M-x replace-regexp ^#$C-qC-j<RET><RET>
This just says "Replaced 0 occurrences" and does nothing. Why is this
so? (I also tried C-m instead of C-j, it doesn't work either. I'm using
Linux)

I was able to achieve what I wanted by first replacing the # lines by
blank lines (the former of the two above), and then removing all blank
lines with
M-x replace-regexp C-qC-jC-qC-j<RET>C-qC-j<RET>
but in general, I may not want to remove all blank lines in the buffer.

So my question is:
a)Why doesn't M-x replace-regexp ^#$C-qC-j<RET><RET> work?
b)What is the regexp I must use to do what I intended?

Thanks,



reply via email to

[Prev in Thread] Current Thread [Next in Thread]