Visual Studio Extension for Code Alignment [closed]

非 Y 不嫁゛ 提交于 2019-12-08 18:48:27

问题


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;

回答1:


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!




回答2:


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.



来源:https://stackoverflow.com/questions/7565367/visual-studio-extension-for-code-alignment

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!