41

Using: Visual Studio Pro 2013

Previous research: [1], [2], [3]

I'm used to working in Java with Eclipse.

My usual flow is: object. CTRL+SPACE + ENTER which autocompletes the method and places the correct curly brackets & method inputs in there:

object.myMethod();
or
object.myMethod(input1,input2);

I'm trying to get the same behaviour with VS in C#. I can get the method, but it doesn't want to include the final brackets for some reason.

I get:

object.myMethod

Is there a way to enable this?

Community
  • 1
  • 1
user3235057
  • 413
  • 1
  • 4
  • 5
  • By default, you can use `space` to auto-complete the current statement. You can find options regarding auto-complete at `Tools`->`Options`->`Text Editor`->`C#`->`IntelliSense`. Further more I'd recommend you to take a look at [ReSharper](http://www.jetbrains.com/resharper/) by JetBrains. It's a common extension for all type of developers using Visual Studio. – Stefan Over Jan 30 '14 at 20:07
  • 12
    Yes, `space` completes the statement but doesn't add brackets. Surely I don't need an extension to add some brackets!? That must be one of the most common tasks!!! – user3235057 Jan 30 '14 at 20:09
  • 3
    I think what your looking for is something like http://www.jetbrains.com/resharper/ – Brendan Green Jan 30 '14 at 20:40
  • 3
    Instead of pressing spacebar for completion, type in an opening bracket, this will complete what you're typing and add both brackets. – Parziphal Feb 10 '18 at 15:16
  • Has anyone found a solution? maybe a free extension with this option or something? – black_gay Mar 02 '21 at 23:07

4 Answers4

5

When doing autocomplete, instead of just hitting ENTER, you can instead press the key combination "Shift + (" and it will autocomplete and add () all in the one.

Murray
  • 51
  • 1
  • 2
2

You can turn on Automatic Brace Completion at: Tools->Options->Text Editor->C#->General .

Tools->Options->Text Editor->C#->IntelliSense is for auto-completion of variables and keywords.

Steve
  • 623
  • 4
  • 11
2

With the current version of Visual Studio 2019 (Version 16.10.x), press the Tab key twice to insert arguments (also brackets). This is an experimental feature and needs to be enabled in Options -> Text Editor -> C# -> IntelliSense -> Tab twice to insert arguments (experimental).

Mihir
  • 419
  • 3
  • 10
1

Even though the question was for Visual Studio 2013, on Visual Studio 2017 you can install ReSharper plugin by JetBrains that among other things, it automatically add brackets to methods when auto-completing.

Lefteris008
  • 899
  • 3
  • 10
  • 29