in reply to Align given substring(s) in lines

As to your example, note perltidy does this too, though of course it only works on Perl and does a whole lot more as well.

$ cat example.pl my $string = 'some value'; # these my $int = 12; # are my $float = 1.2; # scalars $ perltidy -b example.pl $ cat example.pl my $string = 'some value'; # these my $int = 12; # are my $float = 1.2; # scalars

Replies are listed 'Best First'.
Re^2: Align given substring(s) in lines
by johnaj (Sexton) on Apr 28, 2021 at 20:06 UTC
    That's neat -- I've never used perltidy, as I'm not a really big fan of automated/mandated coding style (unless I'm reading obfuscated code), but that's a pretty good use case.
      I'm not a really big fan of automated/mandated coding style (unless I'm reading obfuscated code)

      When I'm writing code, I just write it in my own style anyway, and when working on someone else's code that has a consistent style I usually try to copy that. I basically only use perltidy when someone else's code is hard to read (like some of the questions posted here sometimes have mixed up indentation), and I've worked out my own perltidyrc that produces output that's close enough to my own style. Running perltidy on my code would usually mess up my style in a few small places so I don't do that :-)