Community
    • Login

    Prevent N++ from erasing comments in shortcuts.xml

    Scheduled Pinned Locked Moved Help wanted · · · – – – · · ·
    3 Posts 2 Posters 2.0k 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.
    • Stefan TravisS
      Stefan Travis
      last edited by

      I often edit “shortcuts.xml” by hand, and include comments - between <!-- and --> tags.

      After changing macros from within N++ itself, N++ erases all comments in “shortcuts.xml”. Is there a way to prevent it from doing this?

      1 Reply Last reply Reply Quote 0
      • Stefan TravisS
        Stefan Travis
        last edited by

        I’ve found a way to keep comments in shortcuts.xml, but it’s not neat.

        Paste the line:
        <Action type=“0” message=“2172” wParam=“0” lParam=“0” sParam=“” />

        …and insert comments in the double quotes after sParam. Action 2172 is the scintilla null operation, so the line does nothing. But being able to document the xml without cheating like this would be better.

        Scott SumnerS 1 Reply Last reply Reply Quote 1
        • Scott SumnerS
          Scott Sumner @Stefan Travis
          last edited by

          @Stefan-Travis

          When Notepad++ reads in shortcuts.xml, it parses it for content, not its textual makeup, and keeps the content in memory. When it is time to write out shortcuts.xml, it writes out what it has, which no longer has the comments. It makes sense, but I agree it would be better if it would keep the comments.

          However, I sort of like your “cheat”. Previously, I would use the sParam string of a command that doesn’t use it for anything to store some comments I wanted to leave. But obviously this cannot be done if a line USES its sParam data for something. Since the NULL operation never uses sParam for anything, it is an excellent place for comment text, following lines that already employ the sParam for something useful. Here’s an example of how “the cheat” could be used:

          <Macro name="Mark DUPLICATE LINES (except last occurrence)" 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="(?-s)^(.*)(?:\R)(?s)(?=.*^\1\R)" />
              <Action type="0" message="2172" wParam="0" lParam="0" sParam="2172=NULL(comment):  for 1601:  here's what the regex does..." />
              <Action type="3" message="1602" wParam="0" lParam="0" sParam="" />
              <Action type="3" message="1625" wParam="0" lParam="2" sParam="" />
              <Action type="3" message="1702" wParam="0" lParam="276" sParam="" />
              <Action type="3" message="1701" wParam="0" lParam="1615" sParam="" />
              <Action type="0" message="2316" wParam="0" lParam="0" sParam="" />
              <Action type="2" message="0" wParam="43006" lParam="0" sParam="" />
          </Macro>
          
          1 Reply Last reply Reply Quote 1
          • First post
            Last post
          The Community of users of the Notepad++ text editor.
          Powered by NodeBB | Contributors