简体   繁体   中英

How to disable Using statement (C#) suggestion in Visual Studio Code

I am using Visual Studio Code to write C#, however one thing is driving me crazy...

Whenever I want to add a using directive at the top of the file, it keeps suggesting the "Using statement" which results in a using block, when I just wanted to use a namespace.

For example at the top:

在此处输入图片说明

I begin typing a new using line and this always shows up:

在此处输入图片说明

I always inadvertently accept the suggestion due to quickly hitting enter/tab by habit:

在此处输入图片说明

And now I have to manually clean it up ... every time.

So how do I disable this specific suggestion in Visual Studio Code?

I found it! Extensions are downloaded into (for Windows)

c:\Users\Username\.vscode\extensions

This "Using statement" suggestion came with the C# extension.

So inside

c:\Users\Username\.vscode\extensions\ms-vscode.csharp-1.16.2\snippets\csharp.json

removing the following lines made it go away:

"Using statement": {
    "prefix": "using",
    "body": [
        "using (${1:resource})",
        "{",
        "    $0",
        "}"
    ],
    "description": "Using statement"
},

If I understand your question right then I don't think this can be solved.

Turning a part of Intellisense of is impossible.

Is there any way to disable intellisense for a specific project / namespace / whatever?

EDIT, that is more important than the top part!!: Of course there are ways to change the behaviour of intellisense but I'm not really experienced with that. https://code.visualstudio.com/docs/editor/intellisense

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