防止 Visual Studio Code 中的自动完成功能

203

我正在使用新的Visual Studio Code

在 SQL 文件中,每当您键入 case 时,它会自动添加 end,就好像您正在构建一个 case 块一样。即使您在注释中,或者将 Case 作为单词的一部分(例如,select CaseID from...)。

我想完全禁用所有这些无聊的自动补全,因为它对我自动补全东西的效果不好。

我能找到的唯一配置选项,我已经设置了:

"editor.autoClosingBrackets": false,
"editor.suggestOnTriggerCharacters": false,

我还能做些什么来阻止这种情况的发生?

对于像begin这样的东西也是如此(它会添加end),我相信还有很多类似的情况。


3
一个变通方法是在输入 case 或者 begin 后按下 ^Z。虽然仍有些麻烦。 - zedfoxus
9个回答

313

在最新版本的Visual Studio Code中,我发现

"editor.acceptSuggestionOnCommitCharacter": false

该配置禁用此行为。


126
谢谢你。我原本打算键入“render()”,但却得到了“CanvasRenderingContext2D”的结果,这是怎么回事?!它不允许我输入所要的内容,除非我禁用提交字符。这是一个可怕的默认设置。编辑器不应在未经您允许的情况下替换您键入的内容。 - Brennan Cheung
37
当它突然变成一些奇怪的东西并自动插入一个不需要的符号的导入时,情况会变得更糟。 - Darius
4
@shybovycha,是的,我手动将 "editor.acceptSuggestionOnCommitCharacter" : false 添加到 settings.json,但它并没有按预期工作。我的意思是,即使我重新启动了VScode,它仍然会自动完成。不确定为什么会这样。 - tucq88
6
非常感谢你的帮助,因为使用 getData + ( => __acrt_get_locale_data_prefix() 对我的生产力没有帮助。 - alter_igel
11
我改变了这个,因为在进行JS导入时让我感到很疯狂。然而,我还不得不添加:"editor.quickSuggestions": false,这样每次我输入"const"时,就不会出现一个巨大且无关紧要的列表,需要我在关键字和变量名之间点击ESC - Neil Gaetano Lindberg
显示剩余9条评论

94

截至2016年,Visual Studio Code已经非常棒且准备好了。但是我仍然没有找到一种完全关闭自动完成的方法。

但是他们在文档中提供了一些东西:自定义IntelliSense

基本上,我把这个放在我的settings.json里来尝试在工作区将其关闭。但我还需要验证一下。

// Place your settings in this file to overwrite default and user settings.
{
    // Controls if quick suggestions should show up while typing
    "editor.quickSuggestions": { "other": false, "comments": false, "strings": false },

    // Controls if suggestions should be accepted with "Enter" - in addition to "Tab". Helps to avoid ambiguity between inserting new lines and accepting suggestions.
    "editor.acceptSuggestionOnEnter": "off",

    // Controls the delay in ms after which quick suggestions will show up.
    "editor.quickSuggestionsDelay": 10,

    // Enable word based suggestions
    "editor.wordBasedSuggestions": false
}

1
我可能使用的是新版本,因为这篇文章是以前写的,但对于我来说,“editor.quickSuggestions”是一个对象,我可以调整其中的3个子值:{ “other”:false, “comments”:false, “strings”:false }。另外,也许VS Code足够聪明,能够看到“editor.quickSuggestions”: false,并将所有3个设置为false。 - Brad Cupit
1
我无法按照说明进行操作,请改进答案。 - userJT
5
最近版本将acceptSuggestionOnEnter的设置更改为“off”。 - rjh
4
我无法忍受“基于单词的建议”,因为它倾向于重新建议过去出现的相同拼写错误/错别字;“这是一个函数名称,看起来与真实名称非常相似,但实际上并不是!” - jrh
4
"acceptSuggestionOnEnter" 对我来说仍然是默认的开启状态。啊,关掉它真是松了一口气... 我想我会去烤一些加了香蕉的饼干... - xdhmoore

37

截至2019年5月17日,这对我有效。

"editor.acceptSuggestionOnCommitCharacter": false,
"editor.acceptSuggestionOnEnter": "off",
"editor.hover.enabled": false,
"editor.minimap.enabled": false,
"editor.parameterHints.enabled": false,
"editor.quickSuggestions": false,
"editor.quickSuggestionsDelay": 10,
"editor.suggest.snippetsPreventQuickSuggestions": false,
"editor.suggestOnTriggerCharacters": false,
"editor.wordBasedSuggestions": false,

3
禁用悬停工具提示,请添加以下内容:"editor.hover.enabled": false - Vidar
9
可以再加一点上下文吗? 例如,应该添加在哪里? 是在文件中还是 UI 元素的某个位置? 如果是文件,它准确地在哪里(或如何打开)? - Peter Mortensen
@PeterMortensen 没有真正需要更多的上下文。如果你不确定如何在VSCode中更新设置,那么浏览VSCode设置页面可能会有所帮助。以下是一个少于10秒钟的互联网搜索结果:https://code.visualstudio.com/docs/getstarted/settings - Mark Moretto
1
终于在尝试了所有其他建议之后,这个方法有效!谢谢Charlie。 - HerrimanCoder
1
太棒了!接受回车键建议。这对我有用 :) - Lahiru Jayaratne

29

这不是正确的答案,但可能是更好的选择。将:

编辑器:快速建议延迟

从50毫秒(默认值)增加到500-1000毫秒。

在这种情况下,您将有半秒钟的时间来击败自动完成选项,这对于95%的时间可能已足够,并且您不会失去某些情况下可能需要的功能。


8
好的回答。我已经这样做了。你可以将它设置为更高的数字,挑战自己,看看你是否能比机器更快地自动补全;-) - PatrickT
1
"编辑器.快速建议延迟": 1000000000 :) - Eric

9
在当前版本的Visual Studio Code中,将以下内容添加到您的用户设置中:
"editor.quickSuggestions.other": false

这将禁用大部分错误建议。

这个配置在VS Code 1.69.1上不起作用。 - Abdullah Khaled

6
将此添加到settings.json中:

"editor.suggestOnTriggerCharacters": false,

意为不在触发字符上建议自动完成。

5
我通过进入“设置”>“文本编辑器”>“建议”>“内联建议:启用”并取消勾选框来禁用我的。

(更新)这会被语言设置覆盖,因此您需要进行更多更改。此帖子展示了如何禁用纯文本文件的建议,但您可以按照步骤更改所有语言的设置。如何在Visual Studio Code中禁用纯文本文件的下拉建议

Examples


3

这里是最新的解决方案:

"editor.suggest.showClasses": false,
"editor.suggest.showColors": false,
"editor.suggest.showConstants": false,
"editor.suggest.showConstructors": false,
"editor.suggest.showCustomcolors": false,
"editor.suggest.showDeprecated": false,
"editor.suggest.showEnumMembers": false,
"editor.suggest.showEnums": false,
"editor.suggest.showEvents": false,
"editor.suggest.showFields": false,
"editor.suggest.showFiles": false,
"editor.suggest.showFolders": false,
"editor.suggest.showFunctions": false,
"editor.suggest.showInterfaces": false,
"editor.suggest.showIssues": false,
"editor.suggest.showKeywords": false,
"editor.suggest.showMethods": false,
"editor.suggest.showModules": false,
"editor.suggest.showOperators": false,
"editor.suggest.showProperties": false,
"editor.suggest.showReferences": false,
"editor.suggest.showSnippets": false,
"editor.suggest.showStructs": false,
"editor.suggest.showTypeParameters": false,
"editor.suggest.showVariables": false,
"editor.suggest.showValues": false,
"editor.suggest.showWords": false,
"editor.suggest.showUsers": false,
"editor.suggest.showUnits": false,

// controls bracket auto closing
"editor.autoClosingBrackets": "never",

// controls  specific languages tag auto closing
"html.autoClosingTags": false,
"javascript.autoClosingTags": false,
"typescript.autoClosingTags": false

1
你的答案可以通过添加额外的支持信息来改进。请[编辑]以添加更多细节,例如引用或文档,以便其他人可以确认你的答案是否正确。你可以在帮助中心了解有关如何撰写良好答案的更多信息。 - Community

0

在处理 SQL 文件时禁用 "Visual Studio IntelliCode" 扩展可能比更改对其他文件有用的设置更好。


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接