Insert Text (like a template) without having it typed out

Insert Text (like a template) without having it typed out

9

    Feb 17, 2009#1

    I'd like to create a macro that will insert text like a template does (i.e. all at once rather than inserting each subsequent character). As it is, my macro is something like this:

    InsertMode
    ColumnModeOff
    HexOff
    "TEXT I WANT
    TO HAVE INSERTED
    IS HERE"

    But should I want to undo this, I'd have to hit undo as many times as there are characters inserted.

    To get around this, I could use a template, but I've used my 50 global templates up and I want to assign a keyboard shortcut to it.
    I could also make a macro that would paste the text to surround a selection, i.e.:

    InsertMode
    ColumnModeOff
    HexOff
    UltraEditReOn
    Find SelectText "^s"
    Replace All "^sTEXT I WANT
    TO HAVE INSERTED
    IS HERE"

    But this requires that I select something, even if it's a blank space. Is there anything I can do to get around this? I just want to insert a text/string block cleanly.

    Hah. I think I've kind of solved my own question talking through this, but I want to post this should anyone else need something similar:

    InsertMode
    ColumnModeOff
    HexOff
    " "
    StartSelect
    Key LEFT ARROW
    UltraEditReOn
    Find SelectText "^s"
    Replace All "TEXT I WANT
    TO HAVE INSERTED
    IS HERE"

    This adds a space, selects it, and replaces it with the text you want. Voila, more room for templates in your Macro library. Still, if there's an even cleaner way, please let me know~!

    Thanks for your help,
    Rick

    6,686585
    Grand MasterGrand Master
    6,686585

      Feb 18, 2009#2

      Your final macro is a little bit dangerous. If something is currently selected it will be overwritten with a space. Also your last version needs always 2 undo steps. Here is a much more complicated solution which either uses the current selection or selects something left or right the cursor position depening on the current column before running the replace. If that all fails it inserts a space, selects it and inserts the text with the replace. Only the last one produces 2 undo steps. With the standard settings the last one is needed only on an empty file.

      InsertMode
      ColumnModeOff
      HexOff
      UltraEditReOn
      IfSel
      Find SelectText "^s"
      Replace "^sTEXT I WANT
      TO HAVE INSERTED
      IS HERE"
      ExitMacro
      EndIf
      IfColNum 1
      StartSelect
      Key RIGHT ARROW
      EndSelect
      IfSel
      Find SelectText "^s"
      Replace "TEXT I WANT
      TO HAVE INSERTED
      IS HERE^s"
      Key LEFT ARROW
      ExitMacro
      EndIf
      EndIf
      StartSelect
      Key LEFT ARROW
      EndSelect
      EndIf
      IfSel
      Find SelectText "^s"
      Replace "^sTEXT I WANT
      TO HAVE INSERTED
      IS HERE"
      ExitMacro
      EndIf
      " "
      StartSelect
      Key LEFT ARROW
      EndSelect
      Find SelectText " "
      Replace "TEXT I WANT
      TO HAVE INSERTED
      IS HERE"
      Best regards from an UC/UE/UES for Windows user from Austria

      9

        Feb 18, 2009#3

        OOoh, very nice. And such a quick response from the famous Mofi! Thanks very much for your kind reply and efficient solution.