• Login
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.
  • S
    Stefan Travis
    last edited by May 21, 2017, 5:03 AM

    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
    • S
      Stefan Travis
      last edited by May 21, 2017, 4:50 PM

      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.

      S 1 Reply Last reply May 23, 2017, 2:01 PM Reply Quote 1
      • S
        Scott Sumner @Stefan Travis
        last edited by May 23, 2017, 2:01 PM

        @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
        1 out of 3
        • First post
          1/3
          Last post
        The Community of users of the Notepad++ text editor.
        Powered by NodeBB | Contributors