EditPad ProEditPad Pro

Be More Productive with Your Favorite Text Editor

EditPad Pro Tips and Tricks

      
Only US$ 49.95
Windows 98, ME, NT4, 2000, XP, Vista, and 7
100% satisfied or money back
free trial download

Keystroke Macro to Delete All Lines with Search Matches

EditPad Pro 6 has a new feature that allows you to record and play back keystroke macros. This enables you to automate repetitive editing tasks and create new editing commands that EditPad Pro doesn't support out of the box

Let's start with a macro to delete all lines containing search matches. First, enter the search term in the Search box and select the search options you want. Then move the text cursor to the start of the file.

Select the Start Recording item in the Macros menu. Give the macro a name to begin recording. While recording press F3 to find the next search match, and then press Ctrl+Y to delete the line it's on. Select Stop Recording in the Macros menu to finish the macro.

To delete the line with the next search match, invoke the macro by selecting it from the Macros menu, or by pressing the keyboard shortcut you assigned to it. Deleting search matches one at a time is rather slow. To run a macro repeatedly, select the Organize Macros item in the Macros menu. Select the macro you just recorded. In the Repeat box, enter a number larger than the number of expected search matches, and click the Play Macro button. This will replace all search matches.

A special feature of EditPad Pro's keystroke macros is that a macro will stop running immediately when a search attempt fails to match. E.g. if you tell EditPad Pro to run the macro you just recorded 100 times, but there are only 10 search matches, EditPad Pro will stop playing back the macro after the 11th search match fails. This makes it very easy to use macros to process all search matches. You still need to specify the maximum number of repetitions, to prevent EditPad Pro from getting stuck repeating a macro indefinitely in case the search match never fails for some unforeseen reason.

When you record a macro, EditPad Pro records only exactly those keys you press, and exactly those menu items you select. E.g. the macro you just recorded only contains the Find Next and Delete Line commands. It does not contain the search terms, since you did not change those while recording. This means that you just recorded a generic "delete all lines matching the current search text" macro. If you want to record a macro that uses specific search terms, run the search at least once before recording the macro. This will add the search terms and all options to the History drop-down menu on the Search toolbar. While recording the macro, select that item from the search history. Doing so will record all the search settings into the macro.

When you press a keyboard shortcut associated with a menu item, like F3 for Search|Find Next, the macro will record the menu item rather than the key. If you later assign F3 to another menu item, previously recorded macros will still play back the Find Next command rather than the new menu item you assigned the F3 key to.