Using a newline character in the newstring in M-x replace-regexp
  Home FAQ Contact Sign in
gnu.emacs.help only
 
Advanced search
POPULAR GROUPS

more...

gnu.emacs.help Profile…
 Up
Using a newline character in the newstring in M-x replace-regexp         


Author: Corey Foote
Date: Aug 14, 2008 12:31

Hi,

I've got one more quick question for you guys. The string
I'd like to use as the newstring in M-x replace-regexp contains a few newline
characters. Normally, I insert newlines by typing C-q C-j, but this doesn't
work when calling this function. How do you specify a newline character when
making a call to M-x replace-regexp?

Thanks!

_________________________________________________________________
Got Game? Win Prizes in the Windows Live Hotmail Mobile Summer Games Trivia Contest
http://www.gowindowslive.com/summergames?ocid=TXT_TAGHM
Show full article (1.09Kb)
4 Comments
Re: Using a newline character in the newstring in M-x replace-regexp         


Author: Xah
Date: Aug 14, 2008 13:35

On Aug 14, 12:31 pm, Corey Foote hotmail.com> wrote:
> Hi,
>
> I've got one more quick question for you guys. The string
> I'd like to use as the newstring in M-x replace-regexp contains a few newline
> characters. Normally, I insert newlines by typing C-q C-j, but this doesn't
> work when calling this function. How do you specify a newline character when
> making a call to M-x replace-regexp?

It works for me and should work in any emacs 22. For interactive use,
i think C-q C-j is actually the only way to insert newlines.

If you are calling this function in elisp, you can use “\n”. But
literal line feed should also work...

so i'm not sure what might be your problem?

Xah
http://xahlee.org/

no comments
Re: Using a newline character in the newstring in M-x replace-regexp         


Author: harven
Date: Aug 16, 2008 07:00

> It works for me and should work in any emacs 22. For interactive use,
> i think C-q C-j is actually the only way to insert newlines.

C-o or C-012 RET also work for a query-replace.
C-o does not work by default for an incremental search.
The following code adds this shortcut to the incremental commands.

(define-key isearch-mode-map "\C-o"
(lambda () (interactive)
(isearch-process-search-char ?\n)))
no comments
Re: Using a newline character in the newstring in M-x replace-regexp         


Author: David Combs
Date: Sep 10, 2008 18:52

In article <804f53f5-8387-4b20-a4d5-2a2b4708d529@k30g2000hse.googlegroups.com>,
harven wrote:
>
>> It works for me and should work in any emacs 22. For interactive use,
>> i think C-q C-j is actually the only way to insert newlines.
>
>C-o or C-012 RET also work for a query-replace.
>C-o does not work by default for an incremental search.
>The following code adds this shortcut to the incremental commands.
>
>(define-key isearch-mode-map "\C-o"
> (lambda () (interactive)
> (isearch-process-search-char ?\n)))

Looks nifty -- but what does it do?

1: what's the purpose of defining C-o?

2: what does that function/lambda-expr actually *do*
when it gets called>
(like, how does it get a newline inserted?)

Unfortunately:
Show full article (0.95Kb)
1 Comment
Re: Using a newline character in the newstring in M-x replace-regexp         


Author: Kevin Rodgers
Date: Sep 10, 2008 22:12

David Combs wrote:
> In article <804f53f5-8387-4b20-a4d5-2a2b4708d529@k30g2000hse.googlegroups.com>,
> harven wrote:
>>> It works for me and should work in any emacs 22. For interactive use,
>>> i think C-q C-j is actually the only way to insert newlines.
>> C-o or C-012 RET also work for a query-replace.
>> C-o does not work by default for an incremental search.
>> The following code adds this shortcut to the incremental commands.
>>
>> (define-key isearch-mode-map "\C-o"
>> (lambda () (interactive)
>> (isearch-process-search-char ?\n)))
>
> Looks nifty -- but what does it do?
>
> 1: what's the purpose of defining C-o?

It's shorter and perhaps easier to remember than C-q C-j.
Show full article (1.26Kb)
no comments