[notepad++] Auto-indent in Notepad++

We always write code like this formal:

void main(){
  if(){
    if()
    }

Alt text

But when I use Notepad++, the display is:

void main(){
if(){
if()
}

Alt text

How do I use Notepad++ to auto indent?

Thanks to Jonathan, I have set it, but it does not take any effect. The snapshot is below:

Alt text

I am using Notepad++ version 5.1.3.

This question is related to notepad++ indentation code-formatting

The answer is


For those who using version 7.8.5, the Auto-indent settings is now located at "Settings" -> "Preferences..." -> "Auto-Completion".

enter image description here


In the latest version (at least), you can find it through:

  • Settings (menu)
  • Preferences...
  • MISC (tab)
  • lower-left checkbox list
  • "Auto-indent" is the 2nd option in this group

[EDIT] Though, I don't think it's had the best implementation of Auto-indent. So, check to make sure you have version 5.1 -- auto-indent got an overhaul recently, so it auto-corrects your indenting.


Do also note that you're missing the block for the 2nd if:

void main(){
  if(){
    if() { }  # here
  }
}

Menu TextFX ? TextFX Edit ? Reindent C++ code

enter image description here

But, Notepad++ doesn't come with this "Text FX Character" plugin. You will need to install it via

Plugins ? Plugin Manager ? Show Plugin Manager.

To add shortcut for Indentation.

Click on Settings ? Shortcut Mapper... set the shortcut key you prefer. I prefer Ctrl + =.

Enter image description here


If the TextFX menu does not exist, you need to download & install the plugin. Plugins->Plugin Manager->Show Plugin Manager and then check the plugin TextFX Characters. Click 'install,' restart Notepad++.

In version Notepad++ v6.1.3, I resolve with: Plugin Manager->Show Plugin Manager** and then check the plugin "Indent By Fold"


This may seem silly, but in the original question, Turion was editing a plain text file. Make sure you choose the correct language from the Language menu


In the latest version (at least), you can find it through:

  • Settings (menu)
  • Preferences...
  • MISC (tab)
  • lower-left checkbox list
  • "Auto-indent" is the 2nd option in this group

[EDIT] Though, I don't think it's had the best implementation of Auto-indent. So, check to make sure you have version 5.1 -- auto-indent got an overhaul recently, so it auto-corrects your indenting.


Do also note that you're missing the block for the 2nd if:

void main(){
  if(){
    if() { }  # here
  }
}

This may seem silly, but in the original question, Turion was editing a plain text file. Make sure you choose the correct language from the Language menu


Most developers of text editing programs misuse this name (auto-indent). The correct name is "maintain indentation". Auto-indent is what you actually want, but it is not implemented.

I would also like to see this feature in Notepad++.


In the latest version (at least), you can find it through:

  • Settings (menu)
  • Preferences...
  • MISC (tab)
  • lower-left checkbox list
  • "Auto-indent" is the 2nd option in this group

[EDIT] Though, I don't think it's had the best implementation of Auto-indent. So, check to make sure you have version 5.1 -- auto-indent got an overhaul recently, so it auto-corrects your indenting.


Do also note that you're missing the block for the 2nd if:

void main(){
  if(){
    if() { }  # here
  }
}

Notepad++ will only auto-insert subsequent indents if you manually indent the first line in a block; otherwise you can re-indent your code after the fact using TextFX > TextFX Edit > Reindent C++ code.


In the 6.6.8 version I installed the NppAutoIndent plugin from Plugins > Plugin Manager > Show Plugin Manager. Then I selected the Smart Indent option in Plugin > NppAutoIndent. Hope this helps.


If the TextFX menu does not exist, you need to download & install the plugin. Plugins->Plugin Manager->Show Plugin Manager and then check the plugin TextFX Characters. Click 'install,' restart Notepad++.

In version Notepad++ v6.1.3, I resolve with: Plugin Manager->Show Plugin Manager** and then check the plugin "Indent By Fold"


Try the UniversalIndentGUI plugin for Notepad++. It re-indents code based on some parameters. It worked well for me.


A little update: You can skip the TextFX Plugin and just use Tidy2. Here you can configure your own formating-rules for different types of codes. Easy to install and remove within

Notepad++ > Plugins > Plugin Manager > Show Plugin Manager

and just search for Tidy2 and install it. Done.


You can use 'Indent by fold' plugin. Install it from the plugin manager. It works fine for me.


A little update: You can skip the TextFX Plugin and just use Tidy2. Here you can configure your own formating-rules for different types of codes. Easy to install and remove within

Notepad++ > Plugins > Plugin Manager > Show Plugin Manager

and just search for Tidy2 and install it. Done.


Try to save the file before, then it will indent.


For those who using version 7.8.5, the Auto-indent settings is now located at "Settings" -> "Preferences..." -> "Auto-Completion".

enter image description here


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


There seems to be an option for auto-format of XML at least. It can be found at TextFX -> TextFX HTML Tidy -> Tidy: reindent XML.


Notepad++ will only auto-insert subsequent indents if you manually indent the first line in a block; otherwise you can re-indent your code after the fact using TextFX > TextFX Edit > Reindent C++ code.


First download plugin manager this link then unzip the zip folder and copy this inside your program/ notepad++ folder . then restart your notepad++. then you see plugin manager inside plugin menu . then click plugin manager then click show plugin manager . It shows all your plugin list . from the list in bottom find XML tools , checked it and install it. then restart your notepad++. After open a document then plugins/xml tools/pretty plain(indent text) then enjoy.


For those who use Notepad++ v6.8.1 and later, the auto-indent setting now is placed in menu Settings ? Preferences ? MISC. ? Auto Indent.

Enter image description here


Most developers of text editing programs misuse this name (auto-indent). The correct name is "maintain indentation". Auto-indent is what you actually want, but it is not implemented.

I would also like to see this feature in Notepad++.


For those who use Notepad++ v6.8.1 and later, the auto-indent setting now is placed in menu Settings ? Preferences ? MISC. ? Auto Indent.

Enter image description here


Notepad++ will only auto-insert subsequent indents if you manually indent the first line in a block; otherwise you can re-indent your code after the fact using TextFX > TextFX Edit > Reindent C++ code.


Most developers of text editing programs misuse this name (auto-indent). The correct name is "maintain indentation". Auto-indent is what you actually want, but it is not implemented.

I would also like to see this feature in Notepad++.


First download plugin manager this link then unzip the zip folder and copy this inside your program/ notepad++ folder . then restart your notepad++. then you see plugin manager inside plugin menu . then click plugin manager then click show plugin manager . It shows all your plugin list . from the list in bottom find XML tools , checked it and install it. then restart your notepad++. After open a document then plugins/xml tools/pretty plain(indent text) then enjoy.


In the 6.6.8 version I installed the NppAutoIndent plugin from Plugins > Plugin Manager > Show Plugin Manager. Then I selected the Smart Indent option in Plugin > NppAutoIndent. Hope this helps.


Try the UniversalIndentGUI plugin for Notepad++. It re-indents code based on some parameters. It worked well for me.


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


There seems to be an option for auto-format of XML at least. It can be found at TextFX -> TextFX HTML Tidy -> Tidy: reindent XML.


You can use 'Indent by fold' plugin. Install it from the plugin manager. It works fine for me.


Menu TextFX ? TextFX Edit ? Reindent C++ code

enter image description here

But, Notepad++ doesn't come with this "Text FX Character" plugin. You will need to install it via

Plugins ? Plugin Manager ? Show Plugin Manager.

To add shortcut for Indentation.

Click on Settings ? Shortcut Mapper... set the shortcut key you prefer. I prefer Ctrl + =.

Enter image description here


Try to save the file before, then it will indent.


In the latest version (at least), you can find it through:

  • Settings (menu)
  • Preferences...
  • MISC (tab)
  • lower-left checkbox list
  • "Auto-indent" is the 2nd option in this group

[EDIT] Though, I don't think it's had the best implementation of Auto-indent. So, check to make sure you have version 5.1 -- auto-indent got an overhaul recently, so it auto-corrects your indenting.


Do also note that you're missing the block for the 2nd if:

void main(){
  if(){
    if() { }  # here
  }
}

Examples related to notepad++

How to view Plugin Manager in Notepad++ How to format JSON in notepad++ CR LF notepad++ removal How to install a Notepad++ plugin offline? Find duplicates and delete all in notepad++ How to compare two files in Notepad++ v6.6.8 Notepad++ cached files location How to indent HTML tags in Notepad++ How to change background color in the Notepad++ text editor? How do I stop Notepad++ from showing autocomplete for all words in the file

Examples related to indentation

How to indent/format a selection of code in Visual Studio Code with Ctrl + Shift + F Python IndentationError unindent does not match any outer indentation level How to change indentation mode in Atom? How to set HTML Auto Indent format on Sublime Text 3? "Expected an indented block" error? Indent starting from the second line of a paragraph with CSS Indentation Error in Python How to fix/convert space indentation in Sublime Text? How to make the tab character 4 spaces instead of 8 spaces in nano? IndentationError: unexpected unindent WHY?

Examples related to code-formatting

How do you format code on save in VS Code How do you format code in Visual Studio Code (VSCode) JavaScript Chart.js - Custom data formatting to display on tooltip Is there a command for formatting HTML in the Atom editor? How to auto-indent code in the Atom editor? Code formatting shortcuts in Android Studio for Operation Systems How to auto-format code in Eclipse? How to format code in Xcode? What is the proper way to format a multi-line dict in Python? How do I format XML in Notepad++?