views:

415

answers:

1

Consider the following line of code:

things.Add(new Thing { ID = null, Name = "a thing" });

The whitespace formatting you see there is that which I get when I type the closing ;.

Now, if I ask Visual Studio to reformat my code, or I type a closing } it gets reformatted:

things.Add(new Thing{ID = null, Name = "a thing"});

I prefer the first style of formatting.

I am using ReSharper 4.0 and Visual Studio 2008 SP1.

How can I get them to agree on whitespace around braces?

+2  A: 

I have been having this problem too and, although I've learned to live with it, your question made me want to fix it.

Turns out there's an option in VS that ought to help:

Tools -> Options -> Text Editor -> C# -> Formatting

Deselect Automatically format completed block on } and any other options you find offensive.

For future, you can file defects on the R# Jira site. It's also work searching this site to see if a solution to your problem has already been posted.

Have you tried the R# 4.5 Nightly Builds yet?

EDIT Following your comment:

I like all the other aspects of formatting, so don't want to turn the option off.

I would disable all of the Visual Studio formatting and only use the ReSharper formatting. It's much more configurable. Does this not achieve what you want?

Drew Noakes
Thanks for that Drew - however I like all the other aspects of formatting, so don't want to turn the option off. Looking into the space options it seems that this aspect of the IDE just hasn't yet caught up with the new C# syntax...oh well.
Richard Ev
Have not yet checked out the R# 4.5 nightly builds...will look into that, thanks!
Richard Ev
R# 4.5 has now gone RTM.
Drew Noakes

related questions