Community
    • Login

    macro question re:

    Scheduled Pinned Locked Moved General Discussion
    5 Posts 3 Posters 93 Views 2 Watching
    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.
    • M Offline
      MurraySobol
      last edited by PeterJones

      I am running Notepad++ V8.9.7, 64-bit version on Windows 11 Pro.
      I install/update Notepad++ using an installer package.
      I was trying to add the Global Search stuff and was following these instructions

      • First, we are going to add the macro, described below, within your active shortcut.xml file, right before the line containing </Macros>
              <Macro name="Global Search" 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="(\w)" />
                  <Action type="3" message="1625" wParam="0" lParam="2" sParam="" />
                  <Action type="3" message="1602" wParam="0" lParam="0" sParam="(?1[[=$0=]]:$0)" />
                  <Action type="3" message="1702" wParam="0" lParam="640" sParam="" />
                  <Action type="3" message="1701" wParam="0" lParam="1609" sParam="" />
              </Macro>
      

      Reminder :

      • If you installed N++ with an installer package, your active shortcuts.xml file should be within the folder %AppData%\Notepad++

      • If you installed N++ with a portable package, your active shortcuts.xml file should be along with the Notepad++.exe file, in your install folder

      • You may also define a shortcut for this Global Search macro, by opening the Settings > Shortcut Mapper... > Macros tab and double-clicking on the Global Search line !

      When I tried the above I has 2 issues:

      1. I have a “shortcut"s”.xml, not a shortcut.xml file. I assume this was a typo??
      2. I was unable to create a shortcut for this Global Search, When I open the Settings > Shortcut Mapper… > Macros tab I get this result:
        72789460-c4f0-48bd-964b-d8de8f75c99a-image.jpeg
        I don’t see a Global Search line to double-click on.

      Please advise.


      moderator edit: added > for quoting, fixed underlying markdown to match the original post, so that it’s an accurate representation of what @guy038 wrote in the original post).

      PeterJonesP 1 Reply Last reply Reply Quote 0
      • PeterJonesP Offline
        PeterJones @MurraySobol
        last edited by PeterJones

        @MurraySobol ,

        I assume you are talking about this post by @guy038 . If you’re going to create a new topic based on instructions given in a different topic, the least you could do is link to it. (Or you could have just clicked “reply” on that post, as it would have auto-linked, and kept the discussion in one place rather than fracturing it)

        I assume this was a typo??

        The same post lists both shortcut.xml and shortcuts.xml, so the incorrect one was most likely a typo on @guy038’s part.

        I was unable to create a shortcut for this Global Search,

        73970227-2129-43d4-bb3e-bb4ce3a1c416-image.jpeg

        It’s there for me. Is the macro in the Macro menu yet? If not, did you remember to save the shortcuts.xml file and then exit Notepad++ and restart, because Notepad++ doesn’t re-read that config file for new macros when you save it: you have to exit the app and launch it again to have it reload the config files.


        update: Looking at @guy038 's original, he said,

        Reminder :

        • If you installed N++ with an installer package, your active shortcuts.xml file should be within the folder %AppData%\Notepad++

        • If you installed N++ with a portable package, your active shortcuts.xml file should be along with the Notepad++.exe file, in your install folder

        • You may also define a shortcut for this Global Search macro, by opening the Settings > Shortcut Mapper... > Macros tab and double-clicking on the Global Search line !

        Now :

        • Close and restart Notepad++

        • Paste the French text, below, in a new tab ( I rewrote the same French text in different cases ! )

        He should have had the Close and restart Notepad++ before the You may also define ... – he probably didn’t notice, when typing up the instructions, that it might cause confusion.

        Having read my post, he will most likely fix his original, so that it has accurate instructions for future readers.

        1 Reply Last reply Reply Quote 0
        • M Offline
          MurraySobol
          last edited by

          This question is for @guy038.
          I don’t know if I have modified the shortcuts.xml file correctly, here is my file contents:
          <?xml version=“1.0” encoding=“UTF-8”?>
          <NotepadPlus>
          <InternalCommands />
          <Macro name=“Global Search” 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=“(?=\X)(.)|(?!\X).” />
          <Action type=“3” message=“1625” wParam=“0” lParam=“2” sParam=“” />
          <Action type=“3” message=“1602” wParam=“0” lParam=“0” sParam=“(?1(?=[[=$1=]])\X)” />
          <Action type=“3” message=“1702” wParam=“0” lParam=“640” 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>

          I was trying to find this line: the line containing </Macros> in shortcuts.xml but did not see it.

          PeterJonesP 1 Reply Last reply Reply Quote 0
          • PeterJonesP Offline
            PeterJones @MurraySobol
            last edited by

            @MurraySobol ,

            Please use the </> button on the forum toolbar when you want to paste example text, and put the text where it says code_text when you do that. That way, your example text won’t be interpreted as “markdown”, so that we know that your example text is coming through the way you pasted it.

            @MurraySobol said:
            This question is for @guy038.

            Why limit it, when anyone else with the knowledge can answer as well?

            I don’t know if I have modified the shortcuts.xml file correctly,

            You have not. The <Macro name=...>...</Macro> must be between <Macros> and </Macros>

            here is my file contents:

            <?xml version="1.0" encoding="UTF-8"?>
            <NotepadPlus>
                <InternalCommands />
                    <Macro name="Global Search" 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="(?=\X)(.)|(?!\X)." />
                        <Action type="3" message="1625" wParam="0" lParam="2" sParam="" />
                        <Action type="3" message="1602" wParam="0" lParam="0" sParam="(?1\(\?=[[=$1=]]\)\\X)" />
                        <Action type="3" message="1702" wParam="0" lParam="640" sParam="" />
                        <Action type="3" message="1701" wParam="0" lParam="1609" sParam="" />
                    </Macro>
                <Macros />
                <UserDefinedCommands>
                    ...
                </UserDefinedCommands>
                <PluginCommands />
                <ScintillaKeys />
            </NotepadPlus>
            

            I was trying to find this line: the line containing </Macros> in shortcuts.xml but did not see it.

            Looks like the updated XML libary that Notepad++ now uses is changing empty

                <Macros>
                </Macros>
            

            into

                <Macros />
            

            … which is valid XML, but annoying when people are trying to explain how to edit macros manually.

            To follow @guy038’s instructions, you will have to change

                <Macros />
            

            into

                <Macros>
                </Macros>
            

            and then put the macro inside it, like:

                <Macros>
                    <Macro name="Global Search" 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="(?=\X)(.)|(?!\X)." />
                        <Action type="3" message="1625" wParam="0" lParam="2" sParam="" />
                        <Action type="3" message="1602" wParam="0" lParam="0" sParam="(?1\(\?=[[=$1=]]\)\\X)" />
                        <Action type="3" message="1702" wParam="0" lParam="640" sParam="" />
                        <Action type="3" message="1701" wParam="0" lParam="1609" sParam="" />
                    </Macro>
                </Macros>
            
            1 Reply Last reply Reply Quote 1
            • guy038G Offline
              guy038
              last edited by

              Hello, @murraysobol, @peterjones and All,

              I corrected, in my first post to @troglo37, the spelling mistake on the word shortcuts.xml and rearranged a few lines to make my description more precise !


              Of course, @murraysobol, it’s better to use the second version of my macro. Note, however, that this macro generally replaces a fairly short piece of text with a rather long string of characters ! Therefore, you may need to change a default setting in the Search section of Preferences... if the resulting regular expression becomes too long !

              For example, in my last post to @troglo37, the two lines of the test contains, respectively, 124 and 135 chars and the resulting regexes contains, both, 1,612 chars !

              So, go to Settings > Preferences... > Searching section. Then, in the part When Find Dialog is Invoked, move to the Max Characters to Auto-Fill Find field from Selection option and modify the default 1024 value to a greater value. Personally, I use the maximum 16383 value !

              However, it’s obvious that your initial selection must be as short as possible This macro will be used mainly to get the different spellings of names or surnames !


              An exemple with this INPUT text, below :

              Our friends Šarūnas, Đorđe, Ørjan, Paweł, Ștefania, Ángel and Uğur had already left
              Our friends Sarūnas, Đorđe, Orjan, Paweł, Ștefania, Ángel and Uğur had already left
              Our friends Šarunas, Đorđe, Ørjan, Pawel, Stefania, Ángel and Uğur had already left
              Our friends Šarūnas, Dorde, Ørjan, Paweł, Ștefania, Angel and Ugur had already left
              

              Now if I copy, at random, the third line of this INPUT text somewhere else, select that line and run the Global Search macro, I get this regex :

              (?=[[=O=]])\X(?=[[=u=]])\X(?=[[=r=]])\X(?=[[= =]])\X(?=[[=f=]])\X(?=[[=r=]])\X(?=[[=i=]])\X(?=[[=e=]])\X(?=[[=n=]])\X(?=[[=d=]])\X(?=[[=s=]])\X(?=[[= =]])\X(?=[[=Š=]])\X(?=[[=a=]])\X(?=[[=r=]])\X(?=[[=u=]])\X(?=[[=n=]])\X(?=[[=a=]])\X(?=[[=s=]])\X(?=[[=,=]])\X(?=[[= =]])\X(?=[[=Đ=]])\X(?=[[=o=]])\X(?=[[=r=]])\X(?=[[=đ=]])\X(?=[[=e=]])\X(?=[[=,=]])\X(?=[[= =]])\X(?=[[=Ø=]])\X(?=[[=r=]])\X(?=[[=j=]])\X(?=[[=a=]])\X(?=[[=n=]])\X(?=[[=,=]])\X(?=[[= =]])\X(?=[[=P=]])\X(?=[[=a=]])\X(?=[[=w=]])\X(?=[[=e=]])\X(?=[[=l=]])\X(?=[[=,=]])\X(?=[[= =]])\X(?=[[=S=]])\X(?=[[=t=]])\X(?=[[=e=]])\X(?=[[=f=]])\X(?=[[=a=]])\X(?=[[=n=]])\X(?=[[=i=]])\X(?=[[=a=]])\X(?=[[=,=]])\X(?=[[= =]])\X(?=[[=Á=]])\X(?=[[=n=]])\X(?=[[=g=]])\X(?=[[=e=]])\X(?=[[=l=]])\X(?=[[= =]])\X(?=[[=a=]])\X(?=[[=n=]])\X(?=[[=d=]])\X(?=[[= =]])\X(?=[[=U=]])\X(?=[[=ğ=]])\X(?=[[=u=]])\X(?=[[=r=]])\X(?=[[= =]])\X(?=[[=h=]])\X(?=[[=a=]])\X(?=[[=d=]])\X(?=[[= =]])\X(?=[[=a=]])\X(?=[[=l=]])\X(?=[[=r=]])\X(?=[[=e=]])\X(?=[[=a=]])\X(?=[[=d=]])\X(?=[[=y=]])\X(?=[[= =]])\X(?=[[=l=]])\X(?=[[=e=]])\X(?=[[=f=]])\X(?=[[=t=]])\X
              

              Finally, if you select the 1,079 characters of this regex and open the Find dialog with Ctrl + F, you can easily verify that it matches, successively, the four lines of the INPUT text. Whaooou ;-))

              Note that I could have chosen the first, the second or the fourth line, either. The resulting regexes would have matched the four lines of the INPUT text, as well !

              Best Regards,

              guy038

              1 Reply Last reply Reply Quote 0

              Hello! It looks like you're interested in this conversation, but you don't have an account yet.

              Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.

              With your input, this post could be even better 💗

              Register Login
              • First post
                Last post
              The Community of users of the Notepad++ text editor.
              Powered by NodeBB | Contributors