Microsoft KB Archive/75479

{|
 * width="100%"|

Windows 3.0 Notepad Search and Replace Macro

 * }

Q75479

-

The information in this article applies to:


 * Microsoft Windows versions 3.0, 3.0a

-

SUMMARY
Microsoft Windows 3.0 Notepad has no search-and-replace function. You can, however, make a small macro to get around this by using the macro recorder included with the Windows retail package.

Creating the Macro
The steps to create this macro are as follows:

 Load Recorder as an icon by pressing SHIFT while double-clicking your mouse on the Recorder icon within the Program Manager. Open the file you want to edit within Notepad. Type a string that you would like to use to replace the current string in the file. (For example, if you want to replace &quot;Rename&quot; with &quot;REM,&quot; type REM ). After typing the string, select it with the mouse or press SHIFT+. From the Edit menu, choose Cut. Move to the point in the file that you want to start the search (normally at the top). From the Search menu, choose Find. Type the string that you want to replace. Press ENTER (this should highlight the first occurrence of the string).</li> Double-click the Recorder icon.

<ol style="list-style-type: lower-alpha;"> From the File menu, choose New.</li> From the Macro menu, choose Record.</li> Enter a name for the macro.</li> Choose a hot key that will not conflict with other keys used by Notepad (for example, ALT+BACKSPACE).</li> Select Start.</li></ol> </li> Recorder will record keystrokes only by default, unless you change it.</li> Press DEL, then SHIFT+INSERT, and then F3 (this should replace the first occurrence of the word and find the next).</li> Press CTRL+BREAK (this will stop the recorder).</li> Choose Save.</li> Use the hot key to play back the macro and replace the rest of the occurrences of the string.</li></ol>

Using the Macro
When you want to use the macro later, do the following:


 * 1) Run Recorder.
 * 2) From the File menu, choose Open, and select the macro you created.
 * 3) Run Notepad and open the file.
 * 4) Type a replacement string.
 * 5) From the Edit menu, choose Cut to place the string in the Clipboard.
 * 6) Go to the place in the file that you want to start the search.
 * 7) From the Search menu, choose Find and select the string you want to replace.
 * 8) Type the hot key that you used in step 9d in the &quot;Creating the Macro&quot; section (each time that you press this, it will find the next occurrence of the string and replace it).