Prevent N++ from erasing comments in shortcuts.xml



  • 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?



  • 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.



  • @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>

Log in to reply