如何在 VS Code 中为 Markdown 禁用 IntelliSense?

How to disable IntelliSense in VS Code for Markdown?

我不想在 Visual Studio 代码中对 Markdown 文件进行单词补全,如何禁用它?理想情况下,仅适用于 Markdown,但在最坏的情况下,即使是全局切换也是好的。

可以配置 VS Code 中的 IntelliSense 建议globally or per each workspace and as of 1.9 per file-type (language), using the editor.quickSuggestions, editor.acceptSuggestionOnEnter and editor.suggestOnTriggerCharacters settings

// Controls if quick suggestions should show up or not while typing
"editor.quickSuggestions": true,

文件类型设置(首选,从 1.9 版本开始)

通过按 F1 和 运行 Configure language specific settings 命令打开 Command Palette,然后 select Markdown . 将打开一个新的编辑器窗格,您可以在其中放置这些设置:

// Place your settings in this file to overwrite the default settings
{
  "[markdown]": {
    "editor.quickSuggestions": false
  }
}

这样您将仅针对降价文件禁用 IntelliSense。

全球

F1 打开 Command Palette,键入 open user settings 并按 Enter。将打开一个新的编辑器窗格,您可以在其中放置这些设置:

// Place your settings in this file to overwrite the default settings
{
    "editor.quickSuggestions": false
}

工作空间

Workspace settings 允许设置自定义设置,而无需将它们应用于其他 VS 代码项目。工作区设置文件位于项目的 .vscode 文件夹下。

F1 打开 Command Palette,键入 open workspace settings 并按 Enter。当您可以放置​​与上面列出的相同的片段时,将打开一个新的编辑器窗格。

我不知道目前是否可以将设置与 selected 文件类型相关联。

要配置的其他选项

除了 editor.quickSuggestions 之外,还可以更改其他几个选项以进一步自定义 IntelliSense 的工作方式:

// Controls if quick suggestions should show up while typing
"editor.quickSuggestions": 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": false,

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

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

// Controls if the editor should automatically close brackets after opening them
"editor.autoClosingBrackets": false,

// Controls if suggestions should automatically show up when typing trigger characters
"editor.suggestOnTriggerCharacters": false

除了@JakubS 所说的,还有两个设置可以帮助消除 IntelliSense:

// Controls if the editor should automatically close brackets after opening them
"editor.autoClosingBrackets": false,

// Controls if suggestions should automatically show up when typing trigger characters
"editor.suggestOnTriggerCharacters": false,

editor.autoClosingBrackets 选项将阻止 Visual Studio 代码自动插入右括号、方括号、大括号、单引号、双引号等

editor.suggestOnTriggerCharacters 选项将阻止在您键入美元符号或点时出现自动完成 window。

总而言之,这是我使用的:

// Controls if quick suggestions should show up while typing
"editor.quickSuggestions": 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": false,

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

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

// Controls if the editor should automatically close brackets after opening them
"editor.autoClosingBrackets": false,

// Controls if suggestions should automatically show up when typing trigger characters
"editor.suggestOnTriggerCharacters": false

如果 markdown linting 警告也让人分心并且您想暂时禁用它们,您可以使用;

CTRL/COMMAND+SHIFT+P
Toggle linting by markdownlint on/off (temporarily)

当您认为自己已完成文档时,您可以启用它。

这只适用于纯文本,不适用于降价。我的 settings.json 如下所示,但我仍然在 .md 文件中获得建议(尽管现在不是在 .txt 文件中)。

{
    "[markdown]": {
        "editor.quickSuggestions": false
    },
    "[plaintext]": {
        "editor.quickSuggestions": false
    },
    [other entries]
}