Search and Replace


XEmacs allows you to search for occurrences of a particular string and replace each occurrence with another string. This feature can be invoked by choosing "Replace..." from the "Edit" menu.
 
  • Go to the beginning of the file and then choose "Replace..." from the "Edit" menu or enter the command Esc %.

  •  

     

    The sample file has been deliberately edited, so that some occurrences of the word CONTROL have been changed to ESC. Hence, we will replace occurrences of the word ESC with the word CONTROL.

  • At the command line, you will see the prompt Query replace:. Type the string ESC and press Enter
  • The command prompt should read Query replace ESC with:. Type CONTROL and press Enter
  • The cursor will jump to the first occurrence of the word ESC. In the command line, you will see (? for help). A number of commands are possible at this point:
     
    y or Space replace this occurrence 
    n or Backspace skip to the next occurrence 
    h or Enter quit now 
    . (a period) perform this replacement and then quit 
    ! replace all occurrences from this point onward in the buffer 
    ^ go back to the previous occurrence 
    C-r enter "recursive edit", allowing you to edit and then return to the Query replace by using Esc C-c

     
     
  • For the first occurrence of ESC, choose y. XEmacs will replace it and jump to the next occurrence of ESC
  • For the next occurrence of ESC, choose n. XEmacs will skip this word and find the next occurrence. 
  • Choose n for the next occurrence. Choose ^ to jump back to the occurrence you just skipped. Choose C-r to enter recursive edit. Change the word ESC to CONTROL. Type Esc C-c. This will enter search and replace again. 
  • Press ! and the remaining items will also be changed. 


  • Previous Table of Contents Continue


    Last modified: Tue Jan 6 14:56:47 EST 1998