How to Crop selected text? (delete all in line Except for selected text)

How to Crop selected text? (delete all in line Except for selected text)

20
Basic UserBasic User
20

    Dec 11, 2009#1

    I wish UltraEdit had an option in the context menu or hotkey to CROP. It would look perfect under CUT and COPY.

    Example:

    CUT
    COPY
    CROP
    PASTE

    Anyway, is there a macro to do this? I thought this was a macro that even I could write but I'm not getting anywhere. :)

    Example.

    Say I select the text "regularly read" in the line below....

    IDM does not regularly read or reply to the posts in this forum.

    I hit my crop macro and bam! The result is....

    regularly read

      Dec 11, 2009#2

      Ok, I got it to do what I wanted. Maybe someone could post a better way but it does do what I needed. :D

      Don't laugh!!

      Hotkey "Shift + z"

      InsertMode
      ColumnModeOff
      HexOff
      UltraEditReOn
      IfSel
      Cut
      SelectLine
      Delete
      Paste
      "
      "
      EndIf

      :)

      6,686585
      Grand MasterGrand Master
      6,686585

        Dec 11, 2009#3

        Your macro version was also my first thought. But I don't like destroying the Windows clipboard and it produces too many undo steps. A better version is following:

        InsertMode
        ColumnModeOff
        HexOff
        IfSel
        Clipboard 9
        Copy
        GotoLine 0 1
        StartSelect
        Key END
        Paste
        EndSelect
        ClearClipboard
        Clipboard 0
        EndIf

        This macro works only correct for lines with a line termination on end of every line (or string on end of file). On long lines and soft word wrap enabled it does not work because the GotoLine command sets the cursor always to real start of the line which can be different than start of current display line. For users with an older version of UltraEdit not supporting GotoLine 0 1 (= goto column 1 in current line) following macro does the same as the macro above.

        InsertMode
        ColumnModeOff
        HexOff
        IfSel
        Clipboard 9
        Copy
        Key HOME
        IfColNumGt 1
        Key HOME
        EndIf
        StartSelect
        Key END
        Paste
        EndSelect
        ClearClipboard
        Clipboard 0
        EndIf

        This second macro can be used when working with soft word wrap enabled. It just deletes the string to start and the string to end of the current display line (= part of the long line) resulting in a new long line which is automatically rewrapped.
        Best regards from an UC/UE/UES for Windows user from Austria

        20
        Basic UserBasic User
        20

          Dec 11, 2009#4

          Yes I noticed after using it a bit that it produced to many undo steps.

          Thanks a lot Mofi for posting a much better version. Added to my Macro List. :)