ReSharper and auto closing parentheses
Asked Answered
T

2

35

Is there a way to avoid closing the following parentheses:

String.Format(), or Console.WriteLine() automatically?

Sometimes is this is annoying and unnecessary, and I end up pressing Delete to remove it.

I tried disabling Auto-insert pair brackets, pharentheses and quotes and Auto-insert closing brace and it is still not working...

Tarrasa answered 5/3, 2011 at 3:21 Comment(4)
I felt annoying at the start but now I am so used to the auto close that I never end up using the close braces!Yolandayolande
@Vinod R In fact, I enjoy it, but sometimes it just crashes the code (in more than one scenario)Tarrasa
I'm surprised it's not working for you. I just tried it here. Can you elaborate on precisely what you do? (Also, 5.1 has been out for some time -- perhaps you're experiencing a bug that has since been fixed? Current version is 5.1.3)Beckman
@Kirk I'm not sure about what I need to elaborate. I turned off those two features, restarted VS and the same parentheses are still being closed. I will take a look at the changelogs at JetBrains site...Tarrasa
T
45

The following options should be unchecked/checked in Resharper if you do not want autocomplete feature on parenthesis (all options can be accessed through Visual Studio > ReSharper > Options... > Environment)

To disable parenthesis auto insert in non method calls (as pointed out in the question, you have already disabled it)

  • Editor > Auto-insert pair brackets, pharentheses and quotes (unchecked)
  • Editor > Auto-insert closing brace (unchecked)

To disable parenthesis auto insert in method calls

  • Intellisense > Completion Behavior > Automatically insert parenthesis after completion > Opening only (enabled)

    Automatically insert parenthesis after completion

Tested in Visual Studio 2008 with ReSharper 6.0.

Tyrontyrone answered 10/9, 2011 at 3:39 Comment(4)
This does not work for when i type "new InvalidOperationException" it auto completes with opening and closing parenthesis. Your answer only fixes it for methods not for class constructors or attributes.Captious
@JDPeckham, I have checked the second option in VS2010 + Resharper 6. Works as expected for class constructor calls i.e. inserts the opening braces only.Tyrontyrone
Seems to be a bug with opening only. When I able this option, it still adds the closing. I had to disable it completely.Thermophone
Worth noting that once you've stopped R# doing it, you'll then need to stop Studio itself doing it as per #11056300Impoverished
B
4

In Resharper 9.2, I had the same items unchecked as given in Devendra's answer, but still experienced lag when typing parentheses and brackets.

I found that these issues went away by setting Do not complete on values as found in Resharper >> Options > Environment > IntelliSense > Completing Characters. In the Dialog pane that appears, I set the Do not complete on field to (){}. for C# and JavaScript.

Bradleigh answered 21/12, 2016 at 17:41 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.