
If it finds any whitespace it just prints it like it found it. XmlBuilder.generate/2 can produce some whitespace for you when generating textual XML but it requires that no whitespace is there in the contents of the elements in order to do so. Here’s what the parsed form looks like when parsing the verbose XML: ,īasically, those libraries don’t improvise when it comes to whitespace.īut when I fed them an XML text without any whitespace they happily spat out exactly the same, byte-for-byte, compressed XML when asked to format it. I tried parsing the more verbose XML fragment and both floki and xml_builder serialized it exactly as it was before because the whitespace was already there. Usually XML text generators don’t omit whitespace if it’s already there during parsing. Other scripting plugins will behave similarly.Is your original XML text with or without those extra newlines? Once that’s working for you, you can use the PythonScript interface to add it to the Run menu, then use Settings > Shortcut Mapper to assign a keyboard shortcut. nPluginCommand('XML Tools', 'Pretty Print') # runs the plugin command nuCommand(MENUCOMMAND.EDIT_SETREADONLY) # toggles the Notepad++ menu, but only if it's needed
PRETTY XML FORMATTER WINDOWS
nuCommand(MENUCOMMAND.EDIT_CLEARREADONLY) # clears the Windows attribute
PRETTY XML FORMATTER INSTALL
If you don’t like all those Macro limitations, and if you have PythonScript plugin installed (or similar), or are willing to install such, you could use: from Npp import * Once the macro is working for you, you could use Macro > Modify Shortcut, go to TryRO (or whatever you called the macro) and

If it happened to be not read-only at all, then the first run set it Notepad++ read-only, and running it a second time was able to make it writeable and then runs Pretty Print correctly. If it was just Notepad++ read-only, it also works.

If the file was both windows read-only and Notepad++ read-only, that macro works on the first run. I was able to manually edit ↗ the macro to be: If you’re willing to maybe have to run the macro twice, when it happens to not be read-only and you thought it was, then having that 42028 in the macro is not a problem. If it’s the Notepad++ read-only flag (ID= 42028), then you cannot get the current state of that flag in a macro, and deciding whether or not to send that command is not possible (no logic in macros, either).

Once you have a command ID, you can manually edit ↗ the shortcuts.xml file (in %AppData%\Notepad++\shortcuts.xml 🛈 for a normal installation)įor the second, if it’s the system-level read-only flag, then it’s easy, you just have to have the recorded value of the menu ID for the Clear Read-only Flag entry, which is ID= 42033, which you can get by recording the macro. But I will not guarantee it’s the same for you, or that it will remain consistent if you add or remove plugins. For me, the Pretty Print command is ID= 22137, and that stays consistent from run-to-run of my current setup. And there’s the Notepad++ read-only status, which you can toggle with Edit > Set Read-only.įor the first, if you are sure that the menu command IDs won’t be changing (ie, you are not installing new plugins anymore), then if you can figure out what the menu command ID is, it should stay the same from run to run.
