You are currently viewing How to align columns in Notepad++
Notepad++

How to align columns in Notepad++

Here’s a short tip on how to align columns (separated by comma or other character) for text files in Notepad++ for increased readability.

When a delimited text file is opened in Notepad++ (or any other text editor), the content may look something like this:

Non aligned columns in Notepad++
Non aligned columns in Notepad++

Since the columns aren’t aligned, it is quite hard to read the data.

To make the columns aligned (e.g. like in Excel), the plugin TextFX can be used. In Notepad++, select Plugins -> Plugin Manager and check the plugin to install:

TextFX plugin download
TextFX plugin download

Restart Notepad++ when prompted.

Copy the character that is used as a column delimiter (in the example above it is “;”) and select all rows. Next, select TextFX -> TextFX Edit -> Line up multiple lines by (Clipboard Character):

TextFX Line up multiple lines by
TextFX Line up multiple lines by

Now the result should be much more readable:

Aligned columns in Notepad++
Aligned columns in Notepad++

And here is the text that I used in my example:

PK;Name;InvoiceNumber;InvoiceDate;ReferenceNumber;DueDate;Amount
12688564;Tomas Lind;123456;2016-02-17;111;2016-03-17;1000
101;Mr X;88;2016-02-07;0;2016-03-17;100

Tomas Lind

Tomas Lind - Consulting services as SQL Server DBA and Database Developer at High Coast Database Solutions AB.

This Post Has 37 Comments

  1. EddieH

    This plugin doesn’t work with Tab-Delimited txt files.

    1. Tomas Lind

      Hi, as a workaround, you can search and replace tab with | for instance.

      1. CoskunO

        good work around; thanks!

  2. Damian McEvoy

    Just what I was looking for, thanks!

  3. PB

    Thanks! This is what I was looking for

  4. Ryan

    This isn’t working on my CSV. After about the 4th column in extra spaces appear on certain rows pushing things out of line. Re-running the line up command doesn’t fix it.

    1. vna

      You probably have quotes or doublequotes in your content; it recognizes them as something that negates the delimiter

    2. SGT Gogo

      This happened to me too – because I didn’t read the instruction thoroughly…
      1. Copy the delimiting character
      2. Select All rows
      3. Follow the TextFX menu instructions above

      1. vna

        No, that’s not it; i did read and do as described. Removing double quotes worked.

  5. Brian Riback

    I keep trying to do this but am seeing this error, “This tool requires more than one line be selected.” So, I select all and then see another warning “This tool requires exactly one character in the clipboard.” I’m not sure what I’m doing wrong. 🙂 I appreciate any help, in advance.

    1. Tomas Lind

      Hi, I haven’t seen that error… Are you sure you have only one character copied?

    2. SGT Gogo

      This happened to me too – because I didn’t read the instruction thoroughly…
      1. Copy the delimiting character
      2. Select All rows
      3. Follow the TextFX menu instructions above

  6. Frank

    Thanks! Notepad++ continues to amaze me.

  7. Jho

    Not working for csv files T____T

  8. Venkat Devaki

    This is really awesome and very helpful. Thank you.

  9. BaobobMiller

    It’s a great Idea BUT!!!

    In most of the work I do the separator MUST immediately follow the data which means the added spaces have to come BEFORE the data not after.

    The following is an example but you will have to paste it into Notepadd++ to undo the silly “rich text” interference.

    Original
    P 5.3170, 23.2019, 0.0020, 127, 0, 127, 3, Exterminator_Valern
    P 685.0489, 61.0334, -13.9980, 0, 127, 0, 3, Tolkar_Parlone
    P 321.0277, 93.7604, 0.0020, 0, 0, 0, 3, Tacar_Tissleplay

    What TextFX did
    P 5.3170 , 23.2019, 0.0020 , 127, 0 , 127, 3, Exterminator_Valern
    P 685.0489, 61.0334, -13.9980, 0 , 127, 0 , 3, Tolkar_Parlone
    P 321.0277, 93.7604, 0.0020 , 0 , 0 , 0 , 3, Tacar_Tissleplay

    What I needed TextFX to do
    P 5.3170, 23.2019, 0.0020, 127, 0, 127, 3, Exterminator_Valern
    P 685.0489, 61.0334, -13.9980, 0, 127, 0, 3, Tolkar_Parlone
    P 321.0277, 93.7604, 0.0020, 0, 0, 0, 3, Tacar_Tissleplay

    1. BaobobMiller

      Well forget the example from my previous post. The forum removed all the fixes from my example and set EVERYTHING to one space only between blocks of text.

      Either way what I’m getting at is just that you can’t put spaces after the data b4 its comma… You have to back up and add the spaces b4 the data and then move on the the next one.

  10. cbragdon

    Is there a workaround for a two characters delimiter? For example |~. The error message states only one character should be copied.

    Thanks in advance.

    1. Tomas Lind

      Hi, as you noted the plugin requires that you use only one character. But would it be possible to replace |~ with only one character?

      1. cbragdon

        Tomas, thanks for getting back with me on this. No I can switch out any of the characters. Since I work with medical data we have a standard for delimiters. Thanks for your help, highly appreciated.

  11. april

    hi. what if there are no plugins available on my plugin manager?

    1. p

      you, sir, are a star!

  12. Lawrence

    7.5.8 64 bit plugin manager does not have TetFX. Any suggestions for working with CSV to see the columns align?
    (next to uninstalling x64 and installing the 32 bit version)

  13. Anatoliy Tishaev

    Thx a lot for this guide!

  14. Glenn

    Nice. I had to work a bit to revert it though (I needed to do this to update the text in 1 column of a CSV text file and I didn’t want to use Excel). Anyway revert it process:
    1. Use “Search” to confirm 0 instances of an unlikely character – I chose “*”
    2. Use “Replace” to replace all spaces with that character
    3. Use this TextFX plugin to line up the columns
    4. Make the change to the text
    5. Use “Replace” to replace all spaces with null character (nothing)
    6. Use “Replace” to replace all “*” (or whatever character you used in step #1) with a space character
    Tada! I ran a compare across the before and after file and confirmed no change except the additional column I populated.

    1. CURTIS M BRAGDON

      Glenn, thanks for the information..

    2. Mathieu

      I know this is an old post, but in case anyone might find it useful:

      You can do the same by simply doing multiple Replace “[space][delimiter]” -> “[delimiter]” until no matches are found…

  15. Gregory Wilburn

    Too much work for tab-delimited files.

  16. Shay Ceasary

    The plugin does not appear in NPP 64bit v 7.8.5
    If installed manually, it does not work on some machines (I saw that some people got it to work, stated on the SourceForge page), yet not on mine 🙁
    Could someone re-compile the module to fit the 64bit newer NPP versions?

    Regards,
    S.C.

  17. Emiliano Carlevaro

    This plugin doesn’t seem to be available anymore.
    I use Code alignment. Once installe one heads to Plugins/Code alignment/Align by….
    It’s extremely useful when editing tables written in LaTeX.

    Cheers,

  18. Apoorva

    Thanks, this really helped

  19. kyle

    This is great. How would you put the file back to the way it was initially after editing?

  20. RICARDO GASPARETTO

    Rebuild for new npp?!! Tanks!!!

  21. Nemanja Simovic

    Hi,

    This is not working when delimiter is TAB (ASCII #9).

    Regards,
    Nemanja

  22. Reimao

    Hello, Thank you for this post ! It was really helpful and appreciated.

Leave a Reply