0

Is there any vscode extension that helps reformat code into a 'comma first' style?

Why?

Mainly because I personally like it, and my team accepts it.

It's more common in data-analysis and data-research, and these days I mainly live in SQL and DAX and our team encourages it.

Definitely not the most common of practices, but rather common enough for it to be discussed over the web for years. I found that I benefit personally from using it when revisiting my code.

How I deal with it today

Extension

I found an alignment addon for vscode that is language agnostic and helps me cleanup alignment when I use comma-first. Better Align (chouzz.vscode-better-align | 🔗)

However, it doesn't convert from trailing-comma to comma-first, so while it's useful with comma-first styling - it's only relevant after the list is comma-first.

RegEx

The following is a RegEx I use with search-and-replace which works rather well for me, but it's not 'perfect' (for one, it doesn't distinguish between code and multi-line strings):

s: /,$\n([ \t]+)/
r: /\n$1, /

Why ask here?

My searches are not really coming up with relevant results. Mostly I get discussions of pros and cons about the code styling.

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.