Find/replace in overstrike mode

Find/replace in overstrike mode

2
NewbieNewbie
2

    Jun 07, 2006#1

    I'm using UltraEdit 10.00c. I need to do a series of finds and replaces using overstrike mode. I have tried the following:

    Modify ini file & change Column Overstrike to 1 (also tried 2).
    In UltraEdit, press the Insert key to turn on Overstrike mode.
    From the toolbar, Advanced/Configuration, select "overstrike if in overstrike mode".
    Turn on Column Mode.

    I have done all this, and still, when the replacement text is longer than the found text, all the text to the right is being pushed to the right. Please tell me how to stop the text from being pushed to the right. If the spacing doesn't stay as it was originally, when I use the file in the original application, the data is garbled because the spacing is wrong.

    Thanks for your help.

    6,675585
    Grand MasterGrand Master
    6,675585

      Jun 07, 2006#2

      The trick is to insert the replace string in column mode with overstrike mode on while nothing is selected.

      The following macro which needs the macro property Continue if a Find with Replace not found checked will do it, if your file does not contain the character ».

      A short description for understanding the macro function:

      First the macro inserts » at the current cursor position to mark it. Next you can enter the search string for a standard search, no regex.

      All occurencies of the entered string from current cursor position till end of file are marked next also with the » character before the search string. The cursor position will not be changed by this replace.

      If the search string is not found, the macro will exit with switching back to windows clipboard and undo the insertion of character ».

      Then you have to enter the replace string which is cutted to clipboard 9. Now the mode is switched to column mode with overstrike mode. In a loop on every occurence of » (except the first one inserted at start of the macro) the » is deleted and the replace string is pasted over the current content.

      After the loop the cursor is positioned back to initial cursor position which is still marked by the inserted ». The marking character is deleted now and the default edit mode is restored before the macro exits.

      Note: This is a true find/replace in overstrike mode. If your search string is longer then the replace string, the longer end part of the search string will remain in the file.

      InsertMode
      ColumnModeOff
      HexOff
      Clipboard 9
      "»"
      GetString "Enter search string:"
      StartSelect
      Find Up Select "»"
      Key RIGHT ARROW
      Cut
      EndSelect
      Find "^c"
      Replace All "»^c"
      IfNotFound
      Key BACKSPACE
      ClearClipboard
      Clipboard 0
      ExitMacro
      EndIf
      GetString "Enter replace string:"
      StartSelect
      Find Up Select "»"
      Key RIGHT ARROW
      Cut
      EndSelect
      ColumnModeOn
      OverStrikeMode
      Loop
      Find "»"
      IfNotFound
      ExitLoop
      Else
      Delete
      Paste
      EndIf
      EndLoop
      InsertMode
      ColumnModeOff
      Find Up "»"
      Delete
      ClearClipboard
      Clipboard 0


      Well, a more easier solution to replace a shorter search string by a longer replace string with overstrike would be to use the following regular expression. But this regex replace fails if the search string is near the end of the line and there are not enough characters between the end of the search string and the end of the line. This is an UltraEdit style regex search/replace.

      Code: Select all

      Find What:    short search text??
      Replace With: longer replace text
      As you can see, the replace string is 2 bytes longer than the search string, so 2 ? must be added at the end of the search string. ? = matches any single character except newline in UltraEdit style.
      Best regards from an UC/UE/UES for Windows user from Austria

      2
      NewbieNewbie
      2

        Jun 08, 2006#3

        Good evening, Austria :D , and thank you for the wonderful reply. But my goodness, I am really glad I found a work-around. My Find string is shorter than my Replace string, so if I use "ABC " (note the space) as the Find string, and "ABCD" as the Replace string, the replace string overwrites the spacing as required.

        But if I ever want a high-tech solution, I will definitely use yours! From the eastern shore of Lake Champlain in Vermont, USA, thanks again for the help.