Community
    • Login

    Adding more steps to an existing Macro

    Scheduled Pinned Locked Moved Help wanted · · · – – – · · ·
    12 Posts 4 Posters 2.5k Views
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • Terry RT
      Terry R @Robert Or Janet Diebel
      last edited by

      @Robert-Or-Janet-Diebel

      There is a FAQ post here that should have a lot of information for you.

      In saying you do not want to start again, are you referring to recreating the macro with additional steps, or have you already changed the data with the existing macro. In either case I think you would still record the new steps and then work on incorporating them into the existing macro, rather than try to read, intepret and alter the existing macro by essentially programming the extra steps. That would require a lot of effort as the macro isn’t all that easy to understand.

      good luck
      Terry

      Robert Or Janet DiebelR 1 Reply Last reply Reply Quote 2
      • Robert Or Janet DiebelR
        Robert Or Janet Diebel @Terry R
        last edited by

        @Terry-R said in Adding more steps to an existing Macro:

        recreating the macro with additional steps,

        Yes, I wish to add more steps to an existing Macro. I am using RegEx’s to alter the content.

        Alan KilbornA 1 Reply Last reply Reply Quote 0
        • Alan KilbornA
          Alan Kilborn @Robert Or Janet Diebel
          last edited by Alan Kilborn

          @Robert-Or-Janet-Diebel said in Adding more steps to an existing Macro:

          I wish to add more steps to an existing Macro

          The presumption here is that you created the macro via macro recording.
          No, there is no way to add to it, via recording.

          I am using RegEx’s to alter the content.

          Another presumption is that you’ve recorded one replacement operation into your macro, and now you want to add more of those.
          If so, then it is fairly easy to “hand-edit” the macro to include more such operations.

          • exit Notepad++ to make sure that it saves its current configuration
          • make a copy of your shortcuts.xml file (in case something bad happens) :-)
          • restart Notepad++
          • edit shortcuts.xml and locate your macro within it
          • note that there are a block of lines in the macro starting with 1700 and ending with 1701
          • copy and paste that block of lines at the end of the macro
          • edit the (copied) lines that contain your search regex text and your replacement text, to conform to the new replacement operation that you want to add
          • save shortcuts.xml
          • restart Notepad++

          For much more detail, see the user manual page for this, HERE.

          Robert Or Janet DiebelR 1 Reply Last reply Reply Quote 1
          • Robert Or Janet DiebelR
            Robert Or Janet Diebel @Alan Kilborn
            last edited by PeterJones

            @Alan-Kilborn
            My shortcuts.xml - I have 2 Macros - ParaTxt2Raw and RegExTest.
            How do I find them?


            <?xml version="1.0" encoding="UTF-8" ?>
            <NotepadPlus>
                <InternalCommands />
                <Macros>
                    <Macro name="Trim Trailing Space and Save" Ctrl="no" Alt="yes" Shift="yes" Key="83">
                        <Action type="2" message="0" wParam="42024" lParam="0" sParam="" />
                        <Action type="2" message="0" wParam="41006" lParam="0" sParam="" />
                    </Macro>
                </Macros>
                <UserDefinedCommands>
                    <Command name="Get PHP help" Ctrl="no" Alt="yes" Shift="no" Key="112">https://www.php.net/$(CURRENT_WORD)</Command>
                    <Command name="Wikipedia Search" Ctrl="no" Alt="yes" Shift="no" Key="114">https://en.wikipedia.org/wiki/Special:Search?search=$(CURRENT_WORD)</Command>
                    <Command name="Open selected file path in new instance" Ctrl="no" Alt="yes" Shift="no" Key="117">$(NPP_FULL_FILE_PATH) $(CURRENT_WORD) -nosession -multiInst</Command>
                </UserDefinedCommands>
                <PluginCommands />
                <ScintillaKeys />
            </NotepadPlus>
            

            —

            moderator added code markdown around text; please don’t forget to use the </> button to mark example text as “code” so that characters don’t get changed by the forum

            PeterJonesP 1 Reply Last reply Reply Quote 0
            • PeterJonesP
              PeterJones @Robert Or Janet Diebel
              last edited by

              @Robert-Or-Janet-Diebel said in Adding more steps to an existing Macro:

              How do I find them?

              You probably need to open %AppData%\Notepad++\shortcuts.xml, which is the active copy of that file, not the one in your installation directory (which is the one I guess you opened)

              Robert Or Janet DiebelR 3 Replies Last reply Reply Quote 0
              • Robert Or Janet DiebelR
                Robert Or Janet Diebel @PeterJones
                last edited by

                @PeterJones said in Adding more steps to an existing Macro:

                %AppData%\Notepad++\shortcuts.xm

                You nailed it, Thanx a bunch

                1 Reply Last reply Reply Quote 0
                • Robert Or Janet DiebelR
                  Robert Or Janet Diebel @PeterJones
                  last edited by

                  @PeterJones
                  Are comments allowed in shortcuts.xml?

                  PeterJonesP Alan KilbornA 2 Replies Last reply Reply Quote 0
                  • PeterJonesP
                    PeterJones @Robert Or Janet Diebel
                    last edited by

                    @Robert-Or-Janet-Diebel said in Adding more steps to an existing Macro:

                    @PeterJones
                    Are comments allowed in shortcuts.xml?

                    Allowed, yes. Preserved, I don’t think so. If you record a new macro or do anything else in the GUI that affects that file (create a run menu entry, or change shortcut in Shortcut Mapper), I seem to remember that it will rewrite the file without your comments.

                    I have sometimes used the string attribute on a command that doesn’t use it to create a pseudo-comment in a macro… You can search the forum for my posts about macros, and can probably find an example with pseudo-comments.

                    1 Reply Last reply Reply Quote 0
                    • Robert Or Janet DiebelR
                      Robert Or Janet Diebel @PeterJones
                      last edited by Robert Or Janet Diebel

                      @PeterJones
                      OK NOW. I removed the shortcuts.xml file, Stopped/Started Notepad++. It made a new. I modified and it appears to work.
                      Thanx for all the help. This will be so handy!

                      Sorry for not marking code. I will going forward.
                      I cloned and changed the shortcuts.xml.
                      Than stopped/started Notepad++
                      It does not recognize the new file.
                      After changes to the file, or a new file copied in, the Macros I can see in the file are no longer available.


                      <?xml version="1.0" encoding="UTF-8" ?>
                      <NotepadPlus>
                          <InternalCommands />
                          <Macros>
                              <Macro name="Trim Trailing Space and Save" Ctrl="no" Alt="yes" Shift="yes" Key="83">
                                  <Action type="2" message="0" wParam="42024" lParam="0" sParam="" />
                                  <Action type="2" message="0" wParam="41006" lParam="0" sParam="" />
                              </Macro>
                              <Macro name="ParaTxt2Raw2" Ctrl="no" Alt="no" Shift="no" Key="0">
                                  <Action type="3" message="1700" wParam="0" lParam="0" sParam="" />
                                  <Action type="3" message="1601" wParam="0" lParam="0" sParam="\\id.*?\\p" />
                                  <Action type="3" message="1625" wParam="0" lParam="2" sParam="" />
                                  <Action type="3" message="1602" wParam="0" lParam="0" sParam="\\c 1" />
                                  <Action type="3" message="1702" wParam="0" lParam="1794" sParam="" />
                                  <Action type="3" message="1701" wParam="0" lParam="1609" sParam="" />
                                  <Action type="3" message="1700" wParam="0" lParam="0" sParam="" />
                                  <Action type="3" message="1601" wParam="0" lParam="0" sParam="\\[a-z][\s|\r\n]" />
                                  <Action type="3" message="1625" wParam="0" lParam="2" sParam="" />
                                  <Action type="3" message="1602" wParam="0" lParam="0" sParam="" />
                                  <Action type="3" message="1702" wParam="0" lParam="1794" sParam="" />
                                  <Action type="3" message="1701" wParam="0" lParam="1609" sParam="" />
                                  <Action type="3" message="1700" wParam="0" lParam="0" sParam="" />
                                  <Action type="3" message="1601" wParam="0" lParam="0" sParam="\r\n\n" />
                                  <Action type="3" message="1625" wParam="0" lParam="2" sParam="" />
                                  <Action type="3" message="1602" wParam="0" lParam="0" sParam="\r\n" />
                                  <Action type="3" message="1702" wParam="0" lParam="770" sParam="" />
                                  <Action type="3" message="1701" wParam="0" lParam="1609" sParam="" />
                              </Macro>
                          </Macros>
                          <UserDefinedCommands>
                              <Command name="Get PHP help" Ctrl="no" Alt="yes" Shift="no" Key="112">https://www.php.net/$(CURRENT_WORD)</Command>
                              <Command name="Wikipedia Search" Ctrl="no" Alt="yes" Shift="no" Key="114">https://en.wikipedia.org/wiki/Special:Search?search=$(CURRENT_WORD)</Command>
                              <Command name="Open selected file path in new instance" Ctrl="no" Alt="yes" Shift="no" Key="117">$(NPP_FULL_FILE_PATH) $(CURRENT_WORD) -nosession -multiInst</Command>
                          </UserDefinedCommands>
                          <PluginCommands />
                          <ScintillaKeys />
                      </NotepadPlus>
                      

                      —

                      moderator added code markdown around text; please don’t forget to use the </> button to mark example text as “code” so that characters don’t get changed by the forum

                      PeterJonesP 1 Reply Last reply Reply Quote 0
                      • PeterJonesP
                        PeterJones @Robert Or Janet Diebel
                        last edited by PeterJones

                        @Robert-Or-Janet-Diebel said in Adding more steps to an existing Macro:

                        After changes to the file, or a new file copied in, the Macros I can see in the file are no longer available.

                        It works for me. I pasted your example into my active shortcuts.xml file, saved, exited Notepad++, and restarted, and it saw the new macro just fine.

                        3194e349-0f6d-4682-a113-c79cd83af7bf-image.png

                        Are you sure you did things in the right order? The User Manual describes the order of events you must follow if you want to edit a Notepad++ config file with Notepad++ – you have to exit Notepad++ (to make sure that all the changes Notepad++ has queued up are written), then start Notepad++, then do the manual edit, then save and exit (without doing any changes in the GUI) then restart. If you don’t follow that order, Notepad++ will overwrite your changes (if there had been any GUI changes that affect that file) when it exits,

                        1 Reply Last reply Reply Quote 1
                        • Alan KilbornA
                          Alan Kilborn @Robert Or Janet Diebel
                          last edited by PeterJones

                          @Robert-Or-Janet-Diebel said in Adding more steps to an existing Macro:

                          Are comments allowed in shortcuts.xml?

                          You can do this:

                          <Action type="1" message="2172" wParam="0" lParam="0" sParam="I am a comment!!!!!!!!" />

                          1 Reply Last reply Reply Quote 2
                          • First post
                            Last post
                          The Community of users of the Notepad++ text editor.
                          Powered by NodeBB | Contributors