Community
    • Login

    How to clone current document, language included?

    Scheduled Pinned Locked Moved General Discussion
    18 Posts 5 Posters 1.7k 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.
    • Alan KilbornA
      Alan Kilborn @guy038
      last edited by Alan Kilborn

      @guy038 said in How to clone current document, language included?:

      <!-- The line BELOW will save the CURRENT file —>

      For me, if I insert such a standalone line, or indeed, as I mentioned earlier, an xml comment on a non-comment line, Notepad++ removes it the next time something happens that causes it to write out shortcuts.xml.

      Examples of that include: recording a macro, deleting a macro, assigning/removing a shortcut key to anything, changing/deleting a Run menu entry, etc.

      Technically, I don’t think it “removes” it, I think it just starts from scratch in writing the file with what it thinks should be there. Since it knows nothing about my comment – gone!

      This is different from, say english_customizable.xml (or whatever language file you use), which Notepad++ only reads, and never writes to. There, any comments you place, remain.

      1 Reply Last reply Reply Quote 2
      • guy038G
        guy038
        last edited by guy038

        Hi, @alan-kilborn,

        Weird ! For me, I just tried with N++ v7.8.5 and the last 7.9.1 version and the comment remains !?
        Of course, my two releases are local ones !

        Here’s is my debug-info information :

         Notepad++ v7.9.1   (32-bit)
        Build time : Oct 27 2020 - 16:07:12
        Path : D:\@@\791\notepad++.exe
        Admin mode : OFF
        Local Conf mode : ON
        OS Name : Microsoft Windows XP (32-bit) 
        OS Build : 2600.0
        Current ANSI codepage : 1252
        Plugins : mimeTools.dll NppConverter.dll NppExport.dll 
        

        BR

        guy038

        Alan KilbornA 1 Reply Last reply Reply Quote 0
        • Alan KilbornA
          Alan Kilborn @guy038
          last edited by

          Can anyone else replicate either my behavior, or Guy’s ?

          Here’s what I’m using:

          Notepad++ v7.9.1 (32-bit)
          Build time : Nov 2 2020 - 01:03:56
          Path : C:\…\npp.portable\notepad++.exe
          Admin mode : OFF
          Local Conf mode : ON
          OS Name : Windows 10 Enterprise (64-bit)
          OS Version : 1809
          OS Build : 17763.1577
          Current ANSI codepage : 1252

          PeterJonesP 1 Reply Last reply Reply Quote 2
          • PeterJonesP
            PeterJones @Alan Kilborn
            last edited by

            @Alan-Kilborn ,

            I’m with Alan on this one: if I add a comment, save/exit/reload, it’s still there. But if I then record/save a macro, exit and reload, the comment from the existing macro is gone.

            Notepad++ v7.9.1   (64-bit)
            Build time : Nov  2 2020 - 01:07:46
            Path : C:\usr\local\apps\notepad++\notepad++.exe
            Admin mode : OFF
            Local Conf mode : ON
            OS Name : Windows 10 Enterprise (64-bit) 
            OS Version : 1903
            OS Build : 18362.1198
            Current ANSI codepage : 1252
            Plugins : ComparePlugin.dll ExtSettings.dll HexEditor.dll LuaScript.dll MarkdownViewerPlusPlus.dll mimeTools.dll NppConsole.dll NppConverter.dll NppEditorConfig.dll NppExec.dll NppExport.dll NppFTP.dll NppUISpy.dll PreviewHTML.dll PythonScript.dll QuickText.dll RestApiToText.dll TagLEET.dll XMLTools.dll 
            
            astrosofistaA 1 Reply Last reply Reply Quote 1
            • astrosofistaA
              astrosofista @PeterJones
              last edited by

              @PeterJones said in How to clone current document, language included?:

              I’m with Alan on this one: if I add a comment, save/exit/reload, it’s still there. But if I then record/save a macro, exit and reload, the comment from the existing macro is gone.

              Me too !

              Notepad++ v7.9.1 (64-bit)
              Build time : Nov 2 2020 - 01:07:46
              Path : D:\Aplicaciones\npp.7.9.1.portable.x64\notepad++.exe
              Admin mode : ON
              Local Conf mode : ON
              OS Name : Windows 7 Professional (64-bit)
              OS Build : 7601.24546
              Current ANSI codepage : 1252
              Plugins : BetterMultiSelection.dll mimeTools.dll NppConverter.dll NppExport.dll PythonScript.dll

              1 Reply Last reply Reply Quote 1
              • Alan KilbornA
                Alan Kilborn
                last edited by

                I’m wondering if Guy did the correct kind of change during his testing… or if his really works differently.

                1 Reply Last reply Reply Quote 0
                • guy038G
                  guy038
                  last edited by guy038

                  Hello, @dario-de-judicibus-0, @alan-kilborn, @peterjones, @astrosofista and All,

                  As I kept the habit, most of the time, to modify configuration files from outside N++, with Microsoft Notepad, I chose the other method:

                  • I started Notepad++

                  • I opened shortcut.xml, from within N++,

                  • I added this new macro, below, without any associated shortcut

                          <Macro name="TEST COMMENT" Ctrl="no" Alt="yes" Shift="yes" Key="0">
                              <Action type="2" message="0" wParam="42024" lParam="0" sParam="" />
                              <!-- The line BELOW will save the CURRENT file --->
                              <Action type="2" message="0" wParam="41006" lParam="0" sParam="" />
                          </Macro>
                  
                  • I closed the shortcuts.xml tab ( Ctrl + W )

                  • I closed Notepad++ ( ALT + F4 )

                  • I opened shortcuts.xml with Microsoft Notepad => The different comments were still here

                  • I re-started N++

                  • I processed the macro ( Macro > TEST COMMENT menu option ), after adding some blank chars at end of some lines of change.log file => it did trim the trailing spaces and save change.log file !

                  • Again, I closed N++

                  • Viewing again shortcuts.xml with Microsoft Notepad => The different comments were still here

                  • I re-started N++

                  • I opened Shortcuts.xml, from within N++ => All was fine : the comment is still present !

                  So… I do not understand at all !


                  Thus, unlike I said before, it could be related to the operating software itself !? I’ll try this assumption later, on my wife’s W8 laptop… when she’s at work! I know her password but shhh ;-))

                  I’ll just paste all my 791 folder on her laptop’s desktop. Really curious of the result !

                  Best regards,

                  guy038

                  Alan KilbornA 1 Reply Last reply Reply Quote 0
                  • Alan KilbornA
                    Alan Kilborn @guy038
                    last edited by

                    @guy038 said in How to clone current document, language included?:

                    I do not understand at all !

                    From your description, your “workflow” for this doesn’t include anything which will cause Notepad++ itself to need to update shortcuts.xml.

                    After you have your nice comments (manually) added to shortcuts.xml, use the macro recorder to record a simple macro, then save the macro with a name. Then restart Notepad++ and examine shortcuts.xml. You should see your new named macro present but any xml comments you put in the file are now eliminated.

                    PeterJonesP 1 Reply Last reply Reply Quote 0
                    • PeterJonesP
                      PeterJones @Alan Kilborn
                      last edited by

                      @Alan-Kilborn ,

                      I tried further experiments, with extra pseudo-attributes (like <Action type="2" message="0" wParam="42024" lParam="0" sParam="" commentAttribute="value" />) and after saving or deleting a different macro in Notepad++, it still got rid of it – I was hoping it would keep unknown attributes, but it didn’t. :-(

                      Alan KilbornA 1 Reply Last reply Reply Quote 1
                      • guy038G
                        guy038
                        last edited by guy038

                        Hello, @dario-de-judicibus-0, @alan-kilborn, @peterjones, @astrosofista and All,

                        @alan-kilborn,

                        Oh…, I just forgot one line in my previous post, right after the black window text :

                        • I saved the new TEST COMMENT macro ( Ctrl + S ) from within N++

                        I really saved this macro ! Otherwise, I would not have been able to see it in the Macro menu and to execute it, later. !!


                        On the other hand, how you explain that, by default, these comments in the UserDefinedCommands node are kept overs sessions ?

                        		<!--
                        		The following shortcuts are dangerous if your computer is compromised.
                        		(But if your computer is compromised, EVERYTHING IS DANGEROUS!)
                        		Remove the comment and use them at your own risk!!!
                        
                                <Command name="Launch in Firefox" Ctrl="yes" Alt="yes" Shift="yes" Key="88">firefox &quot;$(FULL_CURRENT_PATH)&quot;</Command>
                                <Command name="Launch in IE" Ctrl="yes" Alt="yes" Shift="yes" Key="73">iexplore &quot;$(FULL_CURRENT_PATH)&quot;</Command>
                                <Command name="Launch in Chrome" Ctrl="yes" Alt="yes" Shift="yes" Key="82">chrome &quot;$(FULL_CURRENT_PATH)&quot;</Command>
                                <Command name="Launch in Safari" Ctrl="yes" Alt="yes" Shift="yes" Key="65">safari &quot;$(FULL_CURRENT_PATH)&quot;</Command>
                                <Command name="Send via Outlook" Ctrl="yes" Alt="yes" Shift="yes" Key="79">outlook /a &quot;$(FULL_CURRENT_PATH)&quot;</Command>
                        		-->
                        

                        Now, all this story becomes crazy ! I did not have any problem with my wife’s W8 laptop, too !

                        I mean the comments are well preserved in the shortcuts.xml configuration file, no matter what operations I did !

                        As I said before, I simply copied a folder 791, containing the last portable version of N++, on the desktop

                        And I copied/pasted the original Trim Trailing Space and Save macro, located at beginning of the <Macros> node, with the new name TEST COMMENT, right before the line </Macros> and then saved the modified shortcuts.xml from within N++

                        I have no idea what’s going on ! I also verified the attributes of shortcuts.xml : just the normal A rchived attribute

                        Note that my shortcuts.xml files are UTF-8 encoded files. BTW, do not save the shortcuts.xml with the UTF-8-BOM encoding, by mistake. In this case, all the recorded macros are greyed in the Macro menu !

                        Does anyone have an other suggestion ?

                        Cheers,

                        guy038

                        P.S.* : It’s past lunchtime here, but I’m going to have a bite to eat ;-))

                        Alan KilbornA 1 Reply Last reply Reply Quote 1
                        • Alan KilbornA
                          Alan Kilborn @PeterJones
                          last edited by

                          @PeterJones said in How to clone current document, language included?:

                          I was hoping it would keep unknown attributes…

                          Well, if you know it isn’t being used by a particular action, you can put some “comment text” in the sParam="" area of a non-2172 action, and it will be retained. This keeps the “same line” comment idea alive.

                          But I truly think the “2172” type of comment is probably best/safest, even if it isn’t on the same line that it discusses.

                          I supposed it would be nice to have direct support for a comment="blah blah blah" type attribute. But, the whole idea of hand-editing shortcuts.xml is an advanced concept, rather “hackish”, and a bit dangerous (potential data loss, as discussed), so I’m okay with it the way it is.

                          1 Reply Last reply Reply Quote 2
                          • Alan KilbornA
                            Alan Kilborn @guy038
                            last edited by

                            @guy038 said in How to clone current document, language included?:

                            Now, all this story becomes crazy

                            Does anyone have an other suggestion ?

                            I’m out of ideas for you. :-)

                            PeterJonesP 1 Reply Last reply Reply Quote 0
                            • PeterJonesP
                              PeterJones @Alan Kilborn
                              last edited by

                              @guy038,

                              1. Fresh NPP Portable: 3530d585-310d-44ae-a5c7-234999b8f5e9-image.png

                              2. Duplicate macro, add a variety of comment styles: c53edf2e-f969-486f-8375-309979f9c289-image.png

                              3. Exit/Reload Notepad++: no change to screenshot #2

                              4. Start recording macro, type blah, backspace out blah, save, stop recording, save macro as blah.

                              5. Exit /Reload Notepad++. All comments, including the default original comments, are gone.
                                ac6663c3-4ad6-41a5-8277-2848fa46f442-image.png

                              I don’t know how it works for you, because no matter what I do, any sequence like I just showed, which saves or deletes a macro from the macro-recording panel, gets rid of all comments from the XML.

                              While doing the experiment, I noticed that the default comments from the unedited shortcuts.xml had tabs, whereas in my previous experiment, I had used spaces, so I tried with both styles of comments; the unedited used multi-line comments with only the start/start on a line, and the text of the comment between, so I tried that too. But all of those comments, no matter what style, disappeared.

                              I wish I knew how you got it to keep the comments.

                              1 Reply Last reply Reply Quote 1
                              • guy038G
                                guy038
                                last edited by guy038

                                Hello, @dario-de-judicibus-0, @alan-kilborn, @peterjones, @astrosofista and All,

                                Aaaah ! I’m sorry and apologize for making, all of you, searching hard ! It’s all my fault !

                                Indeed, when @alan-kilborn said :

                                From your description, your “workflow” for this doesn’t include anything which will cause Notepad++ itself to need to update shortcuts.xml

                                I just thought that he was speaking about the fact of saving the shortcuts.xml file with Microsoft Notepad and not from within Notepad++ !

                                But I understood, at once, all the story then @peterjones said :

                                1. Start recording macro, type blah, backspace out blah, save, stop recording, save macro as blah

                                Like you, when I decided to record a new macro and give it a name, and, after closing and restarting N++, all comments were gone away in shortcuts.xml, even those located outside the <Macros> node and, also, the default comments of the initial shortcuts.xml file, located in the UserDefinedCommands section, below :

                                		<!--
                                		The following shortcuts are dangerous if your computer is compromised.
                                		(But if your computer is compromised, EVERYTHING IS DANGEROUS!)
                                		Remove the comment and use them at your own risk!!!
                                
                                        <Command name="Launch in Firefox" Ctrl="yes" Alt="yes" Shift="yes" Key="88">firefox &quot;$(FULL_CURRENT_PATH)&quot;</Command>
                                        <Command name="Launch in IE" Ctrl="yes" Alt="yes" Shift="yes" Key="73">iexplore &quot;$(FULL_CURRENT_PATH)&quot;</Command>
                                        <Command name="Launch in Chrome" Ctrl="yes" Alt="yes" Shift="yes" Key="82">chrome &quot;$(FULL_CURRENT_PATH)&quot;</Command>
                                        <Command name="Launch in Safari" Ctrl="yes" Alt="yes" Shift="yes" Key="65">safari &quot;$(FULL_CURRENT_PATH)&quot;</Command>
                                        <Command name="Send via Outlook" Ctrl="yes" Alt="yes" Shift="yes" Key="79">outlook /a &quot;$(FULL_CURRENT_PATH)&quot;</Command>
                                		-->
                                

                                Wooooh, everything is, again, logic between all our configurations ;-))


                                So, as any macro recording deletes all comments, a simple work-around would be to :

                                • Copy your present shortcuts.xml file as, say, shortcuts_comments.xml

                                • Comment all your macros already created, in the shortcuts_comments.xml, as you like to

                                • Record your new macro, in Notepad++

                                • Close and re-start Notepad++

                                • Open, both, the shortcuts.xml and shortcuts_comments.xml files, in N++

                                • Copy your new macro from the shortcuts.xml file

                                • Paste it in the shortcuts_comments.xml file

                                • Add the wanted comments in the shortcuts_comments.xml file, relative to this new macro

                                • Save the shortcuts_comments.xml file

                                With this method, in addition to having a nice version with comments, that we may post in our site, we also benefit from a backup of the shortcuts.xml file. Indeed, if, by mistake, the shortcuts.xml is deleted, simply copy shortcuts_comments.xml as shortcuts.xml and your comments will even remain in shortcuts.xml until your next macro recording ;-))

                                Best Regards,

                                guy038

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