简体   繁体   中英

Visual Studio Code IntelliSense suggestions don't pop up automatically

I followed the install instructions in https://code.visualstudio.com , but when I write C# code, the IntelliSense suggestions don't pop up automatically, so I must trigger it by using shortcut Command+Space , meanwhile, the suggestions are just from the code I wrote.

Here is the screen capture below:

在此输入图像描述

I checked in https://code.visualstudio.com/Docs/editingevolved , VSCode do support C# IntelliSense.

I don't think it is bug, maybe I did something wrong when installing VSCode. How to solve this problem?

To activate IntelliSense on a .NET project:

  1. Open project folder: File->Open folder...
  2. Click on the flame on your bottom left corner, pick your project 点击火焰
  3. IntelliSense activated! IntelliSense现已激活!

From what I've seen, IntelliSense cannot be activated on a .cs file alone. (See @natemcmaster's answer).

OmniSharp doesn't know where your project files are. In your screenshot, the left sidebar says "You have not opened a folder". OmniSharp will look in your currently opened folder for project files.

  1. Add your folder. File > Open Folder...
  2. Make sure you have a project file (either project.json or your *.csproj files).

This should be enough for OmniSharp to start providing you Intellisense.

You just have to pick up the language type from the bar at the bottom (the button with the flame).

像这样

Try changing the editor.quickSuggestions setting to true in the settings.json file. The settings file may be found in:

Windows: %APPDATA%\\Code\\User\\settings.json

Mac: $HOME/Library/Application Support/User/settings.json

Linux: $HOME/.config/Code/User/settings.json

In my case the problem was that I had 2 versions installed. I was launching from the command prompt and it kept running the older version. In Programs and Features, I removed the one that didn't have "(user)" at the end of the application name, and when I opened Code again, it started downloading packages, one of which was OmniSharp, and then IntelliSense started working.

Note that I was also getting the following warning when opening the older version, and searching for the warning led me to instructions on removing the other version, which in turn fixed the IntelliSense problem:

You are running the system-wide installation of Code, while having the user-wide distribution installed as well. Make sure you're running the Code version you expect.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM