65

In Visual Studio, (and a few other Microsoft editors), you can auto format a document with a simple Ctrl + K, Ctrl + D.

This inserts line breaks and tabbing automatically.

Is there a similar feature in Notepad++?

0

6 Answers 6

25

TextFX has the options to insert line breaks and tabbing:

TextFX

4
23

For JavaScript, the JSTool plugin will do this job.

enter image description here

1
  • 1
    very pleased with formatting result and better than tidy2
    – Iman
    Sep 14, 2015 at 5:43
20

Download the "NppAutoIndent" plugin.  In Notepad++:

Plugins → Plugin manager → Available → NppAutoIndent

The "NppAutoIndent" plugin has 'smart' indentation for C-style languages, such as C/C++, PHP, and Java.  It's the first release, so don't expect it to be flawless, and of course it might not be completely to your preferences.  There is NO support for HTML/XML and such, maybe later, tag matching is much more difficult to implement.  To use it, select your code and:

TextFX → TextFX Edit → Reindent C++ code

If you cannot see TextFX in your menu, you can install its plugin from SourceForge.

References:

2
  • 1
    This seems a bit of a jumbled answer to me. Are you talking about NppAutoIndent or TextFX? It seems to jump from one to the other.
    – Caltor
    Dec 8, 2020 at 10:12
  • 1
    Neither of these plugins are available anymore
    – rollsch
    Feb 7, 2022 at 0:41
5

For markup / xml there's a plugin called 'XML Tools'.

This can be added via the plugin manager inside Notepad++.

1
  • 1
    It can't seem to clean HTML it just says errors in the document without telling me what they are. Jan 11, 2013 at 8:32
4

Here are most of plugins to format your code.

JStool (JSmin):
UniversalIndentGUI ( Enable text auto update' in plugin manager-> UniversalIndentGUI
Shortkey = CTRL+ALT+SHIFT+J )


TextFX : ( Shortkey = CTRL+ALT+SHIFT+B or TextFX > TextFX Html Tidy > Tidy: reindent XML) TextFX has the benefit of wrapping long lines, which XML Tools does not do, but doesn't indent those new lines correctly.


XML Tools : (customized plugin for XML; Shortkey = CTRL+ALT+SHIFT+B or XML Tools > Pretty print [Text indent])
XML Tools complements TextFX by indenting the newly wrapped lines nicely.

0
1

For JSON documents, the JSON Viewer plugin allows a simple CTRL-ALT-SHIFT-M to format the json.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .