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

Author: Srikanta

I write here to help the readers learn and understand computer programing, algorithms, networking, OS concepts etc. in a simple way. I have 20 years of working experience in computer networking and industrial automation.


If you also want to contribute, click here.

5 thoughts on “How to Re-Indent C Code Using Notepad++”

  1. Hi: The latest NotePad++ (version 8-5-4) textFX plugin does not have a “TextFX Edit” dropdown selection for “Reindent C++ Code”. Where has the reindent function been moved? Thanks.

    1. Apparently TextFX plugin is no longer available for latest version of Notepad++. Thanks for notifying this. I’ll try to figure out if any other plugin can serve this purpose.

  2. Doesn’t indent correctly with code like this:

    if (something)
    for(blah)
    count++;

    Will become:

    if (something)
    for(blah)
    count++;

Leave a Reply

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

0
0
1
9
2
0