cpmcgrath / codealignment

http://www.codealignment.com
202 stars 51 forks source link

Regex alignment on preceding characters #82

Closed bruno-trindade closed 5 years ago

bruno-trindade commented 5 years ago

Hello! As a ruby developer, I find myself with hash declarations like this:

{
  foo: 'this is a value',
  foobar: 'this is another one',
  foobarbaz: 'this is not a value.  just kidding, yes it is.'
}

Currently there's no way to align these using this plugin (in VS Code). It would be nice if the Regex would recognize captures and use those for alignment, e.g.: \S+:(\s)\S+ would result in:

{
  foo:       'this is a value',
  foobar:    'this is another one',
  foobarbaz: 'this is not a value.  just kidding, yes it is.'
}

Does this sound like a reasonable feature? I'm not that experienced with C# but I could try to submit a PR if this sounds like something you want to pursue. Thanks!

cpmcgrath commented 5 years ago

Hi Bruno, There's a ticket for this in the codealignment-vscode repository - https://github.com/cpmcgrath/codealignment-vscode/issues/7

Align by regex exists in the Visual Studio/Notepad++ version (https://github.com/cpmcgrath/codealignment/wiki/Aligning-using-Regular-expressions), but regexes in Javascript have significant limitations to them. You can capture groups, but you can only get the value of the group, not the index of the group.

As for your particular example though, you could use align by space - https://github.com/cpmcgrath/codealignment/wiki/Align-by-space (forgive the broken images, I'm doing a clean slate redo of some of my hosting and there's a few things I forgot are referenced in the wiki)

bruno-trindade commented 5 years ago

Just what I needed, thank you!

On Wed, Jan 30, 2019 at 4:49 PM Chris McGrath notifications@github.com wrote:

Closed #82 https://github.com/cpmcgrath/codealignment/issues/82.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/cpmcgrath/codealignment/issues/82#event-2107827504, or mute the thread https://github.com/notifications/unsubscribe-auth/ABK3vTEBdAzru_n7L5SOcP0LR5FvfhSkks5vIhNNgaJpZM4aayQP .