Fog Creek Software
Discussion Board




Welcome! and rules

Joel on Software

ARGH! Stop Formatting my code!!!

Is there a way to get Visual Studio to stop formatting my code C style?  I'd really prefer to move all the code to perl style curly braces.    Any help would be appreciated.

Vince
Wednesday, February 16, 2005

Your only option...

Tools | Options | Text Editor | C# | Formatting

"Leave open brances on same line as construct"

That's it. Anything more complex than that isn't supported. You can, of course, uncheck "Automatically format completed constructs and pasted source", which will make it stop messing with your stuff, but won't help you with auto-formatting and indenting.

Brad Wilson
Wednesday, February 16, 2005

Hehe, oh how I know the feeling.

How about in Word when you intentionally want to capitalize or lower case something, and because of context Word thinks you REALLY want it the other way. That feature has always boggled the mind because even after you then go back and put it back, it goes ahead and "Corrects" you once again. That's one of those "ARGHHHH!  I'LL KILL YOU WORD! I'LL KILL YOU!" moments.

.NET Pundit
Wednesday, February 16, 2005

If the layout of your code is a real issue to you than I envy you. My code problems are usually about what the code does or doesn't, not about the aesthetics of it.

Geert-Jan Thomas
Thursday, February 17, 2005

"My code problems are usually about what the code does or doesn't, not about the aesthetics of it."

Code is READ many more times than it's written, so I can appreciate making it readable, especially if, by changing ONE setting, you could make ALL the code you write henceforth just a bit more readable.

Mr. Analogy {ISV owner}
Thursday, February 17, 2005

Word Bitching !!! My Favorite !!

My favorite is our company has a commonly used acronym, HSI, which Word always 'corrects' for us to HIS. No matter how hard you try, it changes it, even if I turn off all the stupid little features. God, I hate Word !!

NetFreak
Thursday, February 17, 2005

NetFreak - about that Word issue...

Tools --> AutoCorrectOptions

Type in hsi into the replace tag, highlight the line that says "replace hsi with his", and click Delete.

moron
Friday, February 18, 2005

It is pretty easy to get VS to format it how you like - shame the options are so limited to things like brackets on new lines and so on.

In my last company there was a lot of good humoured warfare related to bracket placement... if you don't like someones idea of where brackets should go or they are just lame at formatting, its pretty simple to remove the last bracket in the file and re add it - that formats the whole document to your own personal preferences.  (until we realised it screwed up our source control comparisons!!).

niff
Monday, February 21, 2005

The most annoying about VS.NET code reformatting is in HTML.

Why is it that Visual Studio understands correctly indentation for VB and C# but can't figure it out for HTML.

I write something like this :
<TABLE>
    <TR>
        <TD>
            <INPUT type="button">
            <INPUT type="button">
        </TD>
    </TR>
</TABLE>

And then VS reformats to something like :
<TABLE>
<TR><TD><INPUT type="button"><INPUT
type="button"></TD></TR></TABLE>

Which is the most unreadable way of putting some HTML on a page.

Le Poete
Monday, February 21, 2005

I am convinced that Microsoft simply cannot build a decent HTML editor.

Sassy
Wednesday, February 23, 2005

Visual Studio 2005 will not (allegedly) re-format your HTML unless you ask it to.

Mike Green
Wednesday, February 23, 2005

I noticed a couple of problems with the HTML/ASPX editor in VS.

1) It inserts linebreaks, I guess because it makes things look more readable in the HTML view. This creates random spaces when looking at the page.

2) After adding in a 'changable' page title (mentioned here: http://blogs.wwwcoder.com/shaunakp/articles/1113.aspx), the editor randomly removes the 'runat=server' tag.

I really hope Whidbey fixes these bugs.

Colm O'Connor
Friday, February 25, 2005

Can't one specify another editor for HTML? Just curious.. I'll have to look now.. I'm not at the work PC..

Tim Smallwood
Friday, March 04, 2005

I tend to avoid looking at html 99% of the time when writing .net code.

Steve
Monday, March 07, 2005

Visual Studio 2005 shouldn't touch your code. Scutt Guthrie was touring the new web tools in Europe recently and I think in one demo the editor removed a single space from some HTML, so I'm sure there will still be bugs. Nothing major though.

On top of that, from the looks of the property pages you should be able to achieve pretty much arbitrary formatting of your code (exactly what starts on a new line, what constructs have spaces before or after them, indentation levels etc etc). Presumably you could set it up so you get your own personal style on checkout - tada! No more religious arguments with co-workers. :)

Thom Lawrence
Monday, March 07, 2005

*  Recent Topics

*  Fog Creek Home