I have Notepad++ and I got some XML code which is very long. When I pasted it in Notepad++ there was a long line of code (difficult to read and work with).
I want to know if there is a simple way to make the text readable (by readable I mean properly tabbed code).
I can do it manually, but I want a permanent solution to this as I have faced this several times. I am sure there is a way to do this as I have done it once before a couple of years back, maybe with Visual Studio or some other editor, I don't remember.
But can Notepad++ do it?
You may need to install XML Tools using your plugin manager in order to get this option in your menu.
In my experience, libXML gives nice output but only if the file is 100% correctly formed.
You need to install the XML tool from the Plugins menu item → Plugin Manager → Show Plugin Manager and then check the XML tools, install it and then Ctrl + Alt + Shift + B OR the option for XML Tool above shows up.
If you can't try with Eclipse, do right button, source, and correct indent.
If you are behind a proxy, download it from here.
Then copy XMLTools.dll to the plugins directory and external libraries (four dlls) into the root Notepad++ directory.
Here are most of plugins you can use in Notepad++ to format your XML code.
TextFX has the benefit of wrapping long lines, which XML Tools does not do, but it doesn't indent those new lines correctly.
XML Tools complements TextFX by indenting the newly wrapped lines nicely.
All the previous answers do not define how to add the plugin manager in your Notepad++ installation.
After pasting the .dll file restart Notepad++. Now you can install any plugin. To install a plugin, click on the plugin tab, then go to plugin manager and select the plugin whatever you want.
Note: It's the only version I've found working on Windows 10 Professional x64.
Notepad++ v6.6.3 with plugin "XML Tools" and shortcut Ctrl + Alt + Shift + B works fine.
Download the XML tools from here.
Re-start Notepad++ and you should now see the XMLTools appear in the Plugins menu.
Unzip the ext_libs.zip file and then copy the unzipped DLLs to the Notepad++ installation directory (in the example above: C:\Program Files (x86)\Notepad++).
Re-start Notepad++ and you should finally see the proper XML Tools menu.
The feature I use the most is “Pretty print (XML only – with line breaks)”. This will format any piece of XML with all the proper line spacing.
"But can Notepad++ do it?"
If the XML is invalid, the answer is apparently 'no'. I tried Notepad++ with the Tidy2 and XMLTools plugins. Both give errors similar to "errors encountered, please fix". If you don't care about errors, that's a PITA.
Instead, open it in visual studio then edit -> advanced -> format document. Quick and pretty.
This will do a reasonable job, not perfect, but things will be readable, at least.
UniversalIndentGUI did the job for me, once configured properly as described above.
TextFX would not install and run correctly on an old PC I have running Windows XP. There are instructions above for manual installation of various DLL files, but I'd rather avoid any manual installation.
But the output is still much better than one long line!
Since I see lots of comments about people having problems with the plugin, I thought I'd mention the work around that I use.
I don't know if it qualifies as answering the OP's question exactly, but it's very simple and easy for anyone who is having problems with the plugin.
You can't, granted you don't have access to install plugins. But you probably have or can get Eclipse (Visual Studio can do this too).
The latest version of Notepad++ x64 v7.6.2 on Windows 10 already moved the plugin manager to 'Plugins Admin'.
Old versions of Notepad++ and plugin manager won't work.
Not the answer you're looking for? Browse other questions tagged notepad++ code-formatting or ask your own question.
Why does XML look differently in notepad++ and notepad?