3

I'm having a hard time coming up with how to word this with google.

Context: newly installed Resharper 8 VS 2013 C#

Inside an interface I'm typing this

string Name { get; set; }

And I've got Resharper 8 setup to add the } when I type the { perfect! but I keep typing the get; set; and such. I want to move to the next line property. I'm used to typing the } and I've had it setup before on older resharpers to eat that keystroke which puts me just after the already existing }
At that point, I simply hit enter and off I go, but as it is now this happens:

string Name { get; set; }
}

Is there a setting somewhere I'm missing in this resharper that allows that?

wormiii
  • 157
  • 10
  • Someone added a comment and I edited the post and the comment is gone now, sorry nice person! But they mentioned the lack of spaces, which I've corrected that above. Resharper does put the spaces in there for me. I tried again typing out set; with a space then }, but what happens is an extra space is added that I don't want and still get the extra }. I have changed some resharper settings out of the box, but mostly just formatting. – wormiii Jul 26 '14 at 01:18
  • this is so frustrating because i liked the default VS13pro behavior to begin with, maybe there is a way to only opt-in to resharper "features"? – Nateous Jul 28 '15 at 14:35

2 Answers2

8

I've found a way to fix the issue, however it may have some annoying side-effects (That you can get used to, and I've found nothing really annoying yet) because it's a little workaroundy.

Open ReSharper options page, then in the section Environment select Editor -> Editor Behavior

At the bottom, you should have the checkbox "Auto-insert closing brace" checked and the radiobutton "On typing an opening brace" enabled. Change that selection to "On Enter after an opening brace".

enter image description here

Your closing brace will appear after the ; of get and typing the closing brace now behave normally.

For the side-effects, for example, if you create a class you will have to press Enter for the closing brace to appear (which you would press anyway). It's still kinda annoying but not major.

Before : enter image description here

After : enter image description here


An alternative would be removing the spaces in your properties (e.g. public String Name {get;set;}). For that you can go in R# options, under Code Editing, C# -> Formatting Style -> Spaces and untick "Within single line accessor".

Pierre-Luc Pineault
  • 8,993
  • 6
  • 40
  • 55
  • I think using the "no space" solution is just what's going to work best for me. I don't mind it in this case, but I know I've had it working before. I'll mark this "solved" since it is, but if anything figures out how to do this but with the spaces, let me know. – wormiii Jul 26 '14 at 01:54
0

Since you are on Visual Studio 2013, this might be due to a new feature in 2013 that also provides automatic brace completion, which interferes with that of ReSharper. Luckily, it's easy to turn off, go to Tools - Options, then Text Editor - C#, and uncheck the option:

Igal Tabachnik
  • 31,174
  • 15
  • 92
  • 157