简体   繁体   English

如何在Visual Studio Code中禁用Using语句(C#)建议

[英]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... 我正在使用Visual Studio Code编写C#,但是有一件事使我发疯...

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. 每当我想在文件顶部添加using指令时,当我只想使用名称空间时,它会一直建议“ Using语句”,这会导致using块。

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: 我总是不经意地接受了这个建议,因为它很快就会按习惯按Enter / Tab键:

在此处输入图片说明

And now I have to manually clean it up ... every time. 现在,我必须每次手动清理它。

So how do I disable this specific suggestion in Visual Studio Code? 那么如何在Visual Studio Code中禁用此特定建议?

I found it! 我找到了! Extensions are downloaded into (for Windows) 扩展下载到(对于Windows)

c:\Users\Username\.vscode\extensions

This "Using statement" suggestion came with the C# extension. 这个“使用语句”建议是C#扩展附带的。

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. 转向Intellisense的一部分是不可能的。

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 https://code.visualstudio.com/docs/editor/intellisense

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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