Community
    • Login

    Run truncates two or more spaces to one space

    Scheduled Pinned Locked Moved Help wanted · · · – – – · · ·
    3 Posts 2 Posters 495 Views 2 Watching
    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.
    • László BotkaL Offline
      László Botka
      last edited by

      This command doesn’t works well in Run menu

              <Command name="edit &quot;V:\J\Windows  11&quot; file " Ctrl="yes" Alt="no" Shift="no" Key="0">$(NPP_DIRECTORY)\notepad++.exe "V:\J\Windows  11"</Command>
      
      

      Notepad++ doesn’t open “V:\J\Windows 11” (two spaces) but “V:\J\Windows 11” (one space), and opens/creates it with one space, if I allow.

      How can I encode these two spaces so that they work properly?

      PeterJonesP 1 Reply Last reply Reply Quote 0
      • PeterJonesP Online
        PeterJones @László Botka
        last edited by

        @László-Botka said in Run truncates two or more spaces to one space:

        Notepad++ doesn’t open “V:\J\Windows 11” (two spaces) but “V:\J\Windows 11” (one space), and opens/creates it with one space, if I allow.

        This is a feature of XML (and HTML): text collapses whitespace, so one or more space, tab, or newline characters all collapse into one space character. This is caused by the storage format, not Notepad++ itself.

        How can I encode these two spaces so that they work properly?

        XML uses entities to encode characters. The XML library used by Notepad++ to read shortcuts.xml allows using the five named XML enties, &amp; &lt; &gt; &apos; &quot;, along with the two-digit hex entites, like &#x0D; and &#x0A; for CR and LF, or &#x20; for the space character (ASCII 32 is hex 20). Thus, when I have the command,

        <Command name="edit &quot;V:\J\Windows  11&quot; file " Ctrl="yes" Alt="no" Shift="no" Key="0">cmd /k echo $(NPP_DIRECTORY)\notepad++.exe "V:\J\Windows&#x20;&#x20;11"</Command>
        

        it properly echos two spaces rather than one. So I assume if you remove the cmd /k echo prefix, then it will properly run Notepad++

        Two things as an aside.

        1. $(NPP_FULL_FILE_PATH) is equivalent to $(NPP_DIRECTORY)\notepad++.exe … no reason to build the latter yourself.
        2. Since $(NPP_FULL_FILE_PATH) (or $(NPP_DIRECTORY)\notepad++.exe) often have spaces in the name, it’s best to put quotes around them, so that Windows makes sure to treat them as a single entity.

        Thus, best practice for your command would be,

        <Command name="edit &quot;V:\J\Windows  11&quot; file " Ctrl="yes" Alt="no" Shift="no" Key="0">"$(NPP_FULL_FILE_PATH)" "V:\J\Windows&#x20;&#x20;11"</Command>
        

        So if you change your shortcuts.xml to use that, save, and exit/restart Notepad++, that Run entry should work as you expect.

        1 Reply Last reply Reply Quote 2
        • László BotkaL Offline
          László Botka
          last edited by

          Thank you, your help was very useful and effective.

          1 Reply Last reply Reply Quote 0

          Hello! It looks like you're interested in this conversation, but you don't have an account yet.

          Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.

          With your input, this post could be even better 💗

          Register Login
          • First post
            Last post
          The Community of users of the Notepad++ text editor.
          Powered by NodeBB | Contributors