Is there any free extension to perform code alignment, like Align Assignments with Productivity Power Tools but to align this code:
public int ID;
public string Title;
public string Text;
public decimal Factor;
in that way, or something like that?
public int ID;
public string Title;
public string Text;
public decimal Factor;
How do you fix code alignment in VS code? On Windows: Shift + Alt + F. On Mac: Shift + Option + F. On Linux: Ctrl + Shift + I.
Auto formatting settings in Visual Studio Show activity on this post. Select the text you want to automatically indent. Click menu Edit → Advanced → *Format Selection, or press Ctrl + K , Ctrl + F . Format Selection applies the smart indenting rules for the language in which you are programming to the selected text.
To uninstall an extension, select the Manage gear button at the right of an extension entry and then choose Uninstall from the dropdown menu. This will uninstall the extension and prompt you to reload VS Code.
As Pop Catalin said, Code alignment is what you're after. It's my extension, sorry for not much documentation. It's something that's so much easier to explain with videos, but I'm still to get around to it.
When you align by string it finds the first instance of the string and lines them up. For example if you were to enter '=' then
foo = bar;
foobar = foo;
would become
foo = bar;
foobar = foo;
However, your code doesn't have a common delimiter - except for the space before it. So you can use Align By Space (from the toolbar or ctrl + =, ctrl + space, but you'll have to remove what's already assigned to ctrl + =). Align By Space uses your caret location (you can still select the row you want to align, or let the extension figure it out) and aligns by the first space on each line after your caret location.
Hope that makes sense!
You can try Code alignment ;)
P.S. I haven't tried it myself but it looks like it does what you need, so if it's good you can leave a comment here, so more people will know.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With