How to Re-Indent C Code Using Notepad++

Indentation is very important for readability and manageability of code, especially, if the size of code base fairly big. Badly indented code is very difficult to understand or maintain. Good developers always maintain proper indentation but many times we get codes from internet or other sources which are not properly indented, many times they are not indented at all. Here we’ll see how to re-indent code which are not properly indented using Notepad++. Core Notepad++ does not have the feature to do this but indentation can be done easily using a plugin called TextFX Characters.

Install TextFX Characters Plugin

If TextFX Characters plugin is not installed, then following these steps to install that. If the plugin is already installed, skip these steps.

Open Plugin Manager

  • Open the Plugin Manager by selecting “Plugins->Plugin Manager->Show Plugin Manager” menu.

Install TextFX Characters Plugin

    • Select the “Available” Tab of the “Plugin Manager” window. You’ll see the available plugins that are not yet installed. They are alphabetically sorted. Select the “TextFX Characters” plugin and then press “Install” button. Follow the instruction to successfully install the plugin.

TextFX menu on Menu Bar.

  • Once the plugin is successfully installed the “TextFX” menu will appear on the menu bar. Please remember that you need to restart (close and reopen) the Notepad++ editor to make the plugin function.

Indent Your Code

In this example, we have unindented code like this.
Unindented Code

We’ll see how this code will be properly indented using the “TextFX Characters” plugin.

Indent the code

To indent this sample code, select the “TextFX->TextFX Edit->Reindent C++ code” menu. Your code is already indented. The indented code will look like.

Indented Code

One thought on “How to Re-Indent C Code Using Notepad++”

Leave a Reply

Your email address will not be published. Required fields are marked *