[comp.emacs] simulaneous replacement ?

wittig@gmdzi.UUCP (Georg Wittig) (02/02/90)

Is it possible in EMACS to replace several strings simulaneously? I.e.
if I want to replace all the 'abc's by 'xyz's and all the 'Ag's by 'Tr's and
all the 'E's by 'e's and all the ... See what I mean?

Sure, I can 
M-< M-x replace-string ...
M-< M-x replace-string ...
etc.

But that's much to type, and error-prone.

Any suggestions? Thanks in advance,

-- 
Georg Wittig   GMD-Z1.BI   P.O. Box 1240   D-5205 St. Augustin 1 (West Germany)
email: wittig@gmdzi.uucp   phone: (+49 2241) 14-2294
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
"Freedom's just another word for nothing left to lose" (Kris Kristofferson)

kjones@talos.uu.net (Kyle Jones) (02/04/90)

Georg Wittig writes:
 > Is it possible in EMACS to replace several strings simulaneously? I.e.
 > if I want to replace all the 'abc's by 'xyz's and all the 'Ag's by 'Tr's and
 > all the 'E's by 'e's and all the ... See what I mean?
 > 
 > Sure, I can 
 > M-< M-x replace-string ...
 > M-< M-x replace-string ...
 > etc.
 > 
 > But that's much to type, and error-prone.

You must be complaining about having to retype "M-< M-x replace-string",
since you'll have to type all the search and replacement strings anyway.

There are a few things that you can do.

  1. Bind replace-string to a key.

  2. Instead of typing M-< before each replace pass, use C-u C-@, which may
     be easier to type on your terminal. (On some terminals C-@ can be
     generated by typing CTRL-SPACE, which is consderable easier than any
     META_SHIFT combination.)  Since replace-string pushes point onto the
     mark ring before it starts searching, C-u C-@ will pop this position
     and you'll be back to where you where before the replace.

  3. Use C-x ESC (repeat-complex-command) and edit the replace strings from
     the previous invocation of replace-string.  I wouldn't advise this one
     unless you understand basic Lisp syntax.