[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: regexp to collapse multiple blank lines into one
From: |
Neon Absentius |
Subject: |
Re: regexp to collapse multiple blank lines into one |
Date: |
Mon, 10 Oct 2005 17:28:45 +0000 |
User-agent: |
Mutt/1.4.2.1i |
On Mon, Oct 10, 2005 at 10:35:01AM -0600, Kevin Rodgers wrote:
> B. T. Raven wrote:
> > "Neon Absentius" <absent@sdf.lonestar.org> wrote in message
> > news:mailman.10556.1128865819.20277.help-gnu-emacs@gnu.org...
> >>The following seems to work
> >>
> >>C-M-% \(^C-qC-j\)+ RET \1 RET
> >>
> >>Provided of course that your lines are really blank and do not contain
> >>any spaces, tabs etc.
> >
> > Thanks F.L., P.D., N.A. Neon's solution seems the easiest to me. I need
> > this only because I can't get control chars into the replacement string.
> > The replacement can be a bare RET but you can't replace with less than
> > nothing, i.e. replacing a regexp with nothing and then backspacing to
> > get rid of the blank line.
>
> Why can't you use the same technique to put a control character into the
> replacement string as Neon suggests for the search string/regexp
> (namely, C-q)?
>
Actually that also works. The reason I used "\1" is that I had
already grouped the regexp so it saved me typing.
> I'll admit, I don't understand why that solution works: it appears to
> replace the matched sequence of LFD characters with itself, instead of
> replacing it with just a single LFD character (or nothing at all,
> depending on the desired result).
>
I don't understand what you don't understand :) My solutions replaces
one or more occurences of a regexp with a single occurence. Perhaps
you are worried abour efficiency? that if there is a single occurence
I replace it with itself? In that case you are right. A better
solution would be better:
C-M-% \(^C-qC-j\)\{2,\} RET \1 RET
--
There is no national science just as there is no national
multiplication table; what is national is no longer science.
-- Anton Checov
- repexp to collapse multiple blank lines into one, B. T. Raven, 2005/10/09
- Re: repexp to collapse multiple blank lines into one, Friedrich Laher, 2005/10/09
- Re: repexp to collapse multiple blank lines into one, Peter Dyballa, 2005/10/09
- Re: repexp to collapse multiple blank lines into one, Neon Absentius, 2005/10/09
- Message not available
- Re: regexp to collapse multiple blank lines into one, B. T. Raven, 2005/10/09
- Re: regexp to collapse multiple blank lines into one, Kevin Rodgers, 2005/10/10
- Re: regexp to collapse multiple blank lines into one,
Neon Absentius <=
- Re: regexp to collapse multiple blank lines into one, Kevin Rodgers, 2005/10/10
- Re: regexp to collapse multiple blank lines into one, Neon Absentius, 2005/10/10
- Message not available
- Re: regexp to collapse multiple blank lines into one, Tim X, 2005/10/11
- Re: regexp to collapse multiple blank lines into one, Neon Absentius, 2005/10/11
- Re: regexp to collapse multiple blank lines into one, Peter Dyballa, 2005/10/10
Re: repexp to collapse multiple blank lines into one, David Hansen, 2005/10/10