Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Visual Studio comment position adjusting

Okay, maybe it's a bit noob and silly question but I couldn't google anything

When I'm writing my code in C#, I'm making comments at the end of the command lines

Some lines are longer and some are shorter so the comments are at different positions too

For example:

int N=10; //comment1
SomeFunctionWithLongName() //comment2
AnotherFunction() //comment3

And I'd like to have it in cleaner and neater form:

int N=10;                     //comment1
SomeFunctionWithLongName()    //comment2
AnotherFunction()             //comment3

I can work hard and use tabs and spaces to get the result but it's tedious and gets all destroyed if I change anything in my code

Is there any automatic tool that would set the equal positions for all my comments, adjusted for the longest line

like image 963
RRM Avatar asked Mar 21 '26 03:03

RRM


1 Answers

Well, unfortunately there is no directly option in Visual Studio 2010 for aligment comments like your situation.

But in my mind, I have an idea. There is an extension called Code alignment for Visual Studio 2010 and 2012. Let me show you a piece of code with this extenion;

When you write;

foo = bar();
foobar = foo();

The extension aligns this lines based on = ;

foo    = bar;
foobar = foo;

So when you write your comments, they are automaticly will align like;

foo    = bar; //comment1
foobar = foo; //comment2
like image 130
Soner Gönül Avatar answered Mar 23 '26 15:03

Soner Gönül



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!