I'm trying to align some lines in my code that has comments that could use with some alignment too. I used the notepad++ "Code-Alignment" plugin, 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 end up with 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'd like to take this a step further. I'd like to "re-align" the code one more time, this time on the second set of "equals" signs. Preferably without going through the comments to change the second set of equals signs to be more unique.
End result of what I'd like:
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 have been using
Code Alignment
plugin for a while and found it to be very useful. But it has two major issues from my point of view:I decided to create an alternative:
https://github.com/duzun/nppPyAlignColumn
This is a Python Script for Notepad++ Plugin named
Python Script
, that can be run from Menu. It takes as input any string to be used as delimiter of columns and aligns all the columns in the selected lines.From
Code alignment
v3 it's possible with the help of regular expressions.First you have to align the first equal as you already did, with the ordinary way
Plugins
>Code alignment
>Align by equals
.Then, go to
Plugins
>Code alignment
>Align by...
(or hit Ctrl + Shift + =) and write the following expression:Don't forget to check the "Use regular expressions" option. This expression will align only the last equal, instead of the first.
These two steps will return the desired result: