Link to home
Start Free TrialLog in
Avatar of brokeMyLegBiking
brokeMyLegBiking

asked on

auto-format feature available in C#

one thing I like better about VB.NET over C#.net is that VB.NET will auto-format your code for you, adding capitalization and indentation.

Is this feature available in C#? (capitilization is not of course because C# is case sensitive, but indentation, and other auto-formating  would be nice in order to same me some work)

if it is not available in VS 2003, is it available in VS 2005?

thx

-brokeMyLegBiking
Avatar of AlexFM
AlexFM

This is already available in C# 2003, possibly you need to change Visual Studio settings. See: Tools - Options - Text Editor - C# - Formatting.
ASKER CERTIFIED SOLUTION
Avatar of cupawntae
cupawntae

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of brokeMyLegBiking

ASKER

ok, cool. so you have to press these keys every time you want it to auto-format, there is no way for it to trigger when I press return or hit a ";"  ?

that is helpful. I wish it were more automatic
The VS.NET 2003 editor does not "pretty" any C# code and there is no option for this you could turn on.

Don't know about the 2005 editor.
Edit: This applies to "capitalization" only - indentation works like [cupawntae] wrote.
The only "automatic" feature (to my knowledge) is code completion. E.g. if you type some of a method name and press <ctrl-space> it will complete the name (sometimes with various options listed). In this case, it *will* fix capitalization for you.

E.g. type varName.tostr<ctrl-space> and it'll change to varName.ToString

I find this very useful being a java programmer "in real life", because the capitalization is similar but annoyingly different...

Oh and <tab> works in most cases for completion too...
Actually, I forgot there are actually two more auto-format features, listed in the settings mentioned by AlexFM...

Firstly, when you close a block (i.e. type a '}') it can reformat the code inside the block.

Secondly, it can reformat code that you paste in from another file.

Doesn't do what you're looking for but worth a mention!
ok, thx, that is good to know.