Notepad ++ - align text vertically in multiple columns

I am trying to align some lines in my code that has comments that can be used with some alignment. I used notepad + " Code-Alignment " and aligned the text below.

class Constants(object): VAL_CONST = 5 # Lorem ipsum dolor sit amet = 213 TEST_CONST = 0.2324 # Curabitur condimentum elementum = 32 PARALLEL_CONST = 88 # Vivamus vehicula, mauris nec vehicula pulvinar, urna nibh mollis = 1342 CURVE_SPATIAL_CONST = 0.000005892 # Donec sagittis in lacus = 0.55 

I get the following:

 class Constants(object): VAL_CONST = 5 # Lorem ipsum dolor sit amet = 213 TEST_CONST = 0.2324 # Curabitur condimentum elementum= 32 PARALLEL_CONST = 88 # Vivamus vehicula, mauris nec vehicula pulvinar, urna nibh mollis = 1342 CURVE_SPATIAL_CONST = 0.000005892 # Donec sagittis in lacus %$ 0.55 

However, I would like to take one more step. I would like to β€œre-align” the code again, this time on the second set of equal signs. Preferably, without looking at the comments, to change the second set of equal signs to be more unique.

End of result:

 class Constants(object): VAL_CONST = 5 # Lorem ipsum dolor sit amet = 213 TEST_CONST = 0.2324 # Curabitur condimentum elementum = 32 PARALLEL_CONST = 88 # Vivamus vehicula, mauris nec vehicula pulvinar, urna nibh mollis = 1342 CURVE_SPATIAL_CONST = 0.000005892 # Donec sagittis in lacus = 0.55 
+7
notepad ++
source share
2 answers

From Code alignment v3, it's possible with regular expressions.

First you must align the first equal, as you did, in the usual way Plugins > Code alignment > Align by equals .

Then go to Plugins > Code alignment > Align by... (or press Ctrl + Shift + = ) and write the following expression:

 .+(?<x>=) 

Remember to check the Use Regular Expressions option. This expression will align only the last equal, not the first.

These two steps will return the desired result:

 class Constants(object): VAL_CONST = 5 # Lorem ipsum dolor sit amet = 213 TEST_CONST = 0.2324 # Curabitur condimentum elementum = 32 PARALLEL_CONST = 88 # Vivamus vehicula, mauris nec vehicula pulvinar, urna nibh mollis = 1342 CURVE_SPATIAL_CONST = 0.000005892 # Donec sagittis in lacus = 0.55 
+6
source share

I used the Code Alignment plugin and found it very useful. But I have two main problems from my point of view:

  • it aligns only the first column with the delimiter character
  • it uses the .NET platform, which makes it very slow at startup and adds an extra dependency.

I decided to create an alternative:

https://github.com/duzun/nppPyAlignColumn

This is Python Script for the Notepad ++ plugin called Python Script , which can be launched from the menu. It takes as input any row that will be used as a column delimiter, and aligns all columns in the selected rows.

0
source share

All Articles