36

I have installed the C# extension in VS Code. The problem I am having is, after using a code snippet prop, Intellisense no longer suggests variable types. This happens with other things like ctor as well, it will not autocomplete the class name, for example.

I have tried uninstalling/reinstalling the extension. I have Googled without luck as well.

I expect for Intellisense to suggest variable types, for example. Intellisense does not suggest anything.

Hitting Ctrl+. does suggest the correct fix among the list.

Edit: My project does not have a project.json or *.sln file. I created the project using the command line dotnet new webapi. If that is what is required, how do I add it or get Intellisense working?

0

4 Answers 4

76

By default, intellisense / quick suggestions will not be triggered inside of a snippet. To enable them set

"editor.suggest.snippetsPreventQuickSuggestions": false

true is the default.

Editor > Suggest: Snippets Prevent Quick Suggestions in the Settings UI.

6
  • 5
    this can backfire. if Intellisense suggests something and you click tab to go to the next snippet place, it will complete the suggestion. E.g. for snippet; typing i as variable; Intellisense suggestion:int; click tab; int inserted. But to avoid this, click escape before tab (only if Intellisense prompted)
    – Superior
    Commented Nov 9, 2019 at 9:58
  • 1
    @Superior Why does visual studio not have this problem? Why can't vs code provide the same experience as visual studio?
    – huang
    Commented Aug 16, 2020 at 10:59
  • @JokeHuang Why is that question directed towards me? I don't know
    – Superior
    Commented Aug 16, 2020 at 14:29
  • @Superior isn't there a setting to enable tab to trigger the suggestion if the dropdown is displayed and go to the next snippet placeholder otherwise ?
    – gruvw
    Commented May 8, 2021 at 7:42
  • @Gruvw yes, one posted in this answer. I just said that, to remove the dropdown, you have to click escape
    – Superior
    Commented May 8, 2021 at 9:29
4

Mark answered the question above. If he is able to come back I'll accept his answer.

File > Preferences > Settings

Search for editor.suggest.snippetsPreventQuickSuggestions.

Make sure the box is unchecked.

Thanks Mark!

1

I got the same error and I solved it with this configuration:

enter image description here

0

Visual Studio Code's more advanced editing features (IntelliSense, refactoring tools, etc.) only work in C# files if you have a project.json file or *.sln file that VSCode is aware of.

Open the folder (i.e. open the File menu and click Open Folder...) with the *.sln file or project.json and VSCode will attempt to find all project/solution files in the folder.

If there are multiple projects, you may need to select one from the projects button on the right side of the status bar (bottom of the window).

From the VSCode website:

Selecting a project.json-file is opening a DNX-project and VSCode will load that project plus the referenced projects

Selecting a *.sln-file is opening a MSBuild-project. It will load the referenced *.csproj-projects and sibling or descendant project.json-files but no other project files that are referenced from the solution file.

Selecting a folder will make VSCode scan for *.sln and project.json files and VSCode will attempt to load them all.

2
  • I editing the original question. I do not have a project.json or *.sln file.
    – Richie
    Commented Apr 15, 2019 at 6:08
  • Which IntelliSense extension you are using? If not try to download Visual Studio IntelliCode
    – user3133925
    Commented Apr 15, 2019 at 6:37

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.