Community
    • 登入

    Prevent N++ from erasing comments in shortcuts.xml

    已排程 已置頂 已鎖定 已移動 Help wanted · · · – – – · · ·
    3 貼文 2 Posters 2.0k 瀏覽
    正在載入更多貼文
    • 從舊到新
    • 從新到舊
    • 最多點贊
    回覆
    • 在新貼文中回覆
    登入後回覆
    此主題已被刪除。只有擁有主題管理權限的使用者可以查看。
    • Stefan TravisS
      Stefan Travis
      最後由 編輯

      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 條回覆 最後回覆 回覆 引用 0
      • Stefan TravisS
        Stefan Travis
        最後由 編輯

        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 條回覆 最後回覆 回覆 引用 1
        • Scott SumnerS
          Scott Sumner @Stefan Travis
          最後由 編輯

          @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 條回覆 最後回覆 回覆 引用 1
          • 第一個貼文
            最後的貼文
          The Community of users of the Notepad++ text editor.
          Powered by NodeBB | Contributors