xemacs - how to use replace-regexp

September 9, 2008 – 3:45 pm

The documentation available is terse on how to use the replace-regexp function.  Lately I have needed to do a rather large number of complex replacement’s across code.  Here are some things that I should definitely remember next time:

  1. M-x replace-regexp RET \(.*\)-safe RET \1 RET
    • Parenthesis used for matching values for replace always need to be escaped in emacs.  There are no exceptions and you will go insane if you do not remember this.
  2. \&‘ in newstring stands for the entire text being replaced. You don’t need to match the entire string to add to it.

Sorry, comments for this entry are closed at this time.