RRM
RRM

Reputation: 3451

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

Upvotes: 3

Views: 204

Answers (1)

Soner Gönül
Soner Gönül

Reputation: 98740

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

Upvotes: 2

Related Questions