471,627 Members | 1,716 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,627 software developers and data experts.

Utility to make C# code look pretty


Nothing drives me crazier than having to look at someone's code where the
indentation is sloppy. Some lines are indented 2 spaces, others 10 spaces.
Sometimes there's 10 blank lines between lines of code, others times there's
none. Sometimes there are spaces around boolean operators, sometimes not.
Slopy, sloppy, sloppy! I try to get people to be neat and consistant, but it
doesn't help. Call me anal but I think neat code is a sign or organization
and pride in what you're coding. Is there any utility (maybe already in the
SDK) that can make pretty an existing C# module?

thanks!
Dec 14 '05 #1
7 2596
For VS .NET 2003 I use ReSharper. Not free but a great tool. Just a
customer.

http://www.jetbrains.com/resharper/

-- Mark

Ed Debrot wrote:
Nothing drives me crazier than having to look at someone's code where
the indentation is sloppy. Some lines are indented 2 spaces, others
10 spaces. Sometimes there's 10 blank lines between lines of code,
others times there's none. Sometimes there are spaces around boolean
operators, sometimes not. Slopy, sloppy, sloppy! I try to get people
to be neat and consistant, but it doesn't help. Call me anal but I
think neat code is a sign or organization and pride in what you're
coding. Is there any utility (maybe already in the SDK) that can make
pretty an existing C# module?

thanks!

Dec 14 '05 #2
I'll second that.

I use ReSharper as well, it's wonderful.
Has a menu option to "reformat code" to whatever coding style options you
have currently set.

--
Adam Clauss

"Mark Jerde" <Ma*******@newsgroup.nospam> wrote in message
news:eK***************@tk2msftngp13.phx.gbl...
For VS .NET 2003 I use ReSharper. Not free but a great tool. Just a
customer.

http://www.jetbrains.com/resharper/

-- Mark

Ed Debrot wrote:
Nothing drives me crazier than having to look at someone's code where
the indentation is sloppy. Some lines are indented 2 spaces, others
10 spaces. Sometimes there's 10 blank lines between lines of code,
others times there's none. Sometimes there are spaces around boolean
operators, sometimes not. Slopy, sloppy, sloppy! I try to get people
to be neat and consistant, but it doesn't help. Call me anal but I
think neat code is a sign or organization and pride in what you're
coding. Is there any utility (maybe already in the SDK) that can make
pretty an existing C# module?

thanks!


Dec 14 '05 #3
Cudo's to ReSharper can't code without it anymore!

Dec 14 '05 #4
Ed Debrot wrote:
Nothing drives me crazier than having to look at someone's code where the
indentation is sloppy. Some lines are indented 2 spaces, others 10 spaces.
Sometimes there's 10 blank lines between lines of code, others times there's
none. Sometimes there are spaces around boolean operators, sometimes not.
Slopy, sloppy, sloppy! I try to get people to be neat and consistant, but it
doesn't help. Call me anal but I think neat code is a sign or organization
and pride in what you're coding. Is there any utility (maybe already in the
SDK) that can make pretty an existing C# module?

thanks!


For me, the built-in Visual Studio indentation works pretty well. You
can download Visual C# 2005 Express for free that includes the same
great text editor as the full versions.

Just my opinion.
Dec 14 '05 #5
One trick of the IDE that people might have missed... (only works for a
single file at a time, though)

[Ctrl]+A, [Ctrl]+C, [Ctrl]+V

As in, "select all", "copy", "paste"; when the IDE pastes the code (over the
existing in this case), it reshapes it using "standard" indentation and
doing braces etc according to the user's current preferences. Not ideal, but
very quick.

After previous posts, I am now looking at reshaper, though ;-p

Marc

"Ed Debrot" <de****@addsys.com> wrote in message
news:%2****************@TK2MSFTNGP10.phx.gbl...

Nothing drives me crazier than having to look at someone's code where the
indentation is sloppy. Some lines are indented 2 spaces, others 10 spaces.
Sometimes there's 10 blank lines between lines of code, others times
there's
none. Sometimes there are spaces around boolean operators, sometimes not.
Slopy, sloppy, sloppy! I try to get people to be neat and consistant, but
it
doesn't help. Call me anal but I think neat code is a sign or organization
and pride in what you're coding. Is there any utility (maybe already in
the
SDK) that can make pretty an existing C# module?

thanks!

Dec 15 '05 #6

Now that's awesome. I really just wanted to get the spacing right and
sure enough you're solution was simple and easy. Thanks a lot! It even
added spaces where there were none in lines like

+=new ...

becase

+= new ...

and replaced spaces with tabs, provided that's how I had my editor
setup.

thanks again!

*** Sent via Developersdex http://www.developersdex.com ***
Dec 15 '05 #7
I think the credit here really has to go to the VS2005 development team.
Damned handy feature, though ;-p

Glad I could help,

Marc
"Ed Debrot" <de****@addsys.com> wrote in message
news:%2****************@TK2MSFTNGP09.phx.gbl...

Now that's awesome. I really just wanted to get the spacing right and
sure enough you're solution was simple and easy. Thanks a lot! It even
added spaces where there were none in lines like

+=new ...

becase

+= new ...

and replaced spaces with tabs, provided that's how I had my editor
setup.

thanks again!

*** Sent via Developersdex http://www.developersdex.com ***

Dec 15 '05 #8

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

1 post views Thread by Mark Lookabaugh | last post: by
30 posts views Thread by just say NO to PDF | last post: by
2 posts views Thread by Steve Manes | last post: by
8 posts views Thread by Susan Bricker | last post: by
1 post views Thread by jfathman | last post: by
2 posts views Thread by R. Ian Lee | last post: by
27 posts views Thread by Neil | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.