[gnu.emacs] search and replace

alanw@django.berkeley.edu (Alan Weinstein) (01/23/89)

I would like to use the search and replace feature to replace each
occurence of a certain string by a "carriage return".  Can anyone tell
me how to do this?

Alan Weinstein
alanw@cartan.berkeley.edu

montnaro@sprite.steinmetz.ge.com (Skip Montanaro) (01/24/89)

In article <19331@agate.BERKELEY.EDU> alanw@django.berkeley.edu
(Alan Weinstein) writes:
   I would like to use the search and replace feature to replace each
   occurence of a certain string by a "carriage return".  Can anyone tell
   me how to do this?

To enter a carriage return or line feed in the replacement string, prefix it
by C-q (quoted-insert). I suspect Alan really wants a line feed (C-j), not a
carriage return (C-m).

This brings up a point that I'd like to suggest as a bug fix or enhancement
for GNU Emacs (hence my cross-posting to gnu.emacs.bug). I would like to see
two extensions to the minibuffer functionality:

1. truncate-lines should be set to nil in the minibuffer, and to make it
useful,

2. the minibuffer should grow during its use to accommodate all the lines of
text that it contains.

When you stick a literal line feed in the minibuffer, it breaks the input
into two lines and you're left looking at a blank line. Of course, you can
use C-n and C-p to navigate up and down, but I'd prefer it if the entire
minibuffer was made visible. (I realize that you can grow the minibuffer
using C-x ^. I'd like that growth to be automatic.) When the command
executes, the minibuffer should revert to a single line.
--
Skip Montanaro (montanaro@sprite.steinmetz.ge.com, montanaro@ge-crd.arpa)

chris@spock (Chris Ott) (01/24/89)

> I would like to use the search and replace feature to replace each
> occurence of a certain string by a "carriage return".  Can anyone tell
> me how to do this?

     Use the regular search-and-replace command (ESC-%). When you need to
enter the <return>, precede it with Ctrl-Q (i.e. Ctrl-Q,<ret>).

> Alan Weinstein
> alanw@cartan.berkeley.edu

Chris

-------------------------------------------------------------------------------
 Chris Ott
 Computational Fluid Mechanics Lab        Infatuation is blind, not love. A
 University of Arizona                      person in love can see the other's
                                            faults, but loves them anyway.
 Internet: chris@spock.ame.arizona.edu
 UUCP: {allegra,cmcl2,hao!noao}!arizona!amethyst!spock!chris
-------------------------------------------------------------------------------