Tapatalk

How to run macro only within selected text

How to run macro only within selected text

16
Basic UserBasic User
16

    Mar 27, 2006#1

    (thanks mrainey if you read this .. for the help in the other forum concerning displaying macros from list view.. not sure how I missed that).

    Anyway, I'm looking over the macro options and have been searching the macro forum, but can't seem to find something simple... I want to run a macro (one that delete all extra spaces between characters) but only within the text I have selected. I have the macro to remove the extra spaces but I can't seem to get to work on ONLY the text I have selected.

    Thanks in advance for any help.

    6,685587
    Grand MasterGrand Master
    6,685587

      Mar 27, 2006#2

      IfSel
      UnixReOff
      Find RegExp " +"
      Replace All SelectText " "
      EndIf

      Add UnixReOn or PerlReOn (v12+ of UE) at the end off the macro before EndIf if you do not use UltraEdit style expressions by default - see search configuration. Macro command UnixReOff sets the regular expression option to UltraEdit style.
      Best regards from an UC/UE/UES for Windows user from Austria

      16
      Basic UserBasic User
      16

        Mar 27, 2006#3

        Thanks Mofi, It works great!

        (Side note: I didn't 'SelectText' as an option in the help file under the macro commands under Help>>MacroMenu>>Edit Macros. Also is the 'SelectText' that you have bold above saying "Do the replace all in the selectED text?" SelectText sounds like a macro verb for 'DOING a selection' - not working WITHIN a selected text region. But maybe I'm maybe I'm missing what that line is doing. I'm just happy it works, but would like to understand it so I can write my own better.)

        Thanks

        6,685587
        Grand MasterGrand Master
        6,685587

          Mar 28, 2006#4

          The macro was generated by simply recording the replace. If you look at the replace dialog you can see the option Selected Text in the Replace Where box.

          But you are right that macro option SelectText should be better named SelectedText although it is clear that a replace function cannot select a text. But I think, this option cannot be renamed anymore because of compatibility.
          And you are right that the option SelectText is not correctly described in the macro help. There a user can read about the option SelectedText. I will report this help mistake to IDM.
          If you select the Replace command in the edit macro dialog you will see all 3 possible options for the replace command in the parameters box with correct named option SelectText.
          Best regards from an UC/UE/UES for Windows user from Austria

          16
          Basic UserBasic User
          16

            Mar 28, 2006#5

            Thanks Mofi! And thanks for all your other macros I found by searching the forum archives.

            (I did actually put a suggestion in to IDM concerning that I think at least the "remove blank lines in selected text" should be a standard formatting option. It seems to be a common question people have - and yes it is brought up in the faq and simple enough to do with a regEx search/replace, however, I think it couldn't hurt having that as extra format option since it seems like a pretty common task. I'm actually using the macro you showed for that since I have to use it quite often - I 'think' I modified yours correctly to work within selected text - at least it's working:).