Run truncates two or more spaces to one space
-
This command doesn’t works well in Run menu
<Command name="edit "V:\J\Windows 11" 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?
-
@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,& < > ' "
, along with the two-digit hex entites, like
and

for CR and LF, or 
for the space character (ASCII 32 is hex20
). Thus, when I have the command,<Command name="edit "V:\J\Windows 11" file " Ctrl="yes" Alt="no" Shift="no" Key="0">cmd /k echo $(NPP_DIRECTORY)\notepad++.exe "V:\J\Windows  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.
$(NPP_FULL_FILE_PATH)
is equivalent to$(NPP_DIRECTORY)\notepad++.exe
… no reason to build the latter yourself.- 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 "V:\J\Windows 11" file " Ctrl="yes" Alt="no" Shift="no" Key="0">"$(NPP_FULL_FILE_PATH)" "V:\J\Windows  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. -
Thank you, your help was very useful and effective.