Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How To Auto-Format / Indent XML/HTML in Notepad++

Is there a way to re-indent a block of code? I'm looking for something similar to Ctrl+Shift+F in Eclipse (Auto-Format/Indent).

To be clear,

  • I already know how to format XML outside of Notepad++ (Eclipse works fine, as mentioned) so I don't need a bunch of links to other XML-formatting tools.
  • I'm specifically working with XML and HTML.
  • Ideally, there's a keybinding as convenient as the one in Eclipse, so I don't have to break my workflow.

I already know about NppAutoIndent - it won't work, as I'm working with XML, HTML and CSS.

like image 261
SBoss Avatar asked Aug 19 '11 06:08

SBoss


People also ask

Can Notepad++ auto Indent?

So if you indent one line while typing, Notepad++ will maintain that indentation on subsequent lines, until you change the indent level one way or the other. If you use a plugin like XML Tools, you can use the plugin's menu to “pretty print” the XML/HTML, but that's not a live as-you-type formatting.

How do I format an XML file?

To access XML formatting options, choose Tools > Options > Text Editor > XML, and then choose Formatting.


2 Answers

Since I upgraded to 6.3.2, I use XML Tools.

  • install XML Tools via the Plugin Admin (Plugins → Plugins Admin... Then search for "XML Tools", check its box and click the "Install" button).
  • use the shortcut Ctrl+Alt+Shift+B (or menu → Plugins → XML Tools → Pretty Print)

enter image description here

enter image description here

In older versions: menu → TextFX → HTML Tidy → Tidy: Reindent XML.

like image 193
remipod Avatar answered Sep 21 '22 01:09

remipod


Install Tidy2 plugin. I have Notepad++ v6.2.2, and Tidy2 works fine so far.

like image 33
Dima Avatar answered Sep 22 '22 01:09

Dima