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

70

我不想在Visual Studio Code中为Markdown文件启用单词自动完成,如何禁用它?最好只针对Markdown文件禁用,但在最坏的情况下,全局禁用也可以。

4个回答

122
在VS Code中,IntelliSense建议可以进行全局或每个工作区的配置,自从1.9版本开始,可以按文件类型(语言)进行配置,使用editor.quickSuggestions, editor.acceptSuggestionOnEntereditor.suggestOnTriggerCharacters设置。请注意保留{和}符号。
// Controls if quick suggestions should show up or not while typing
"editor.quickSuggestions": true,

自从VSCode 1.11 版本以来,quickSuggestions 设置允许更加细粒度地控制快速建议。然而,该设置只接受布尔值或匹配IQuickSuggestionsOptions的对象,并默认为true。将其设置为false会完全禁用快速建议。

文件类型设置(推荐使用1.9版本以上)

按下F1打开命令面板,运行配置语言特定设置命令,然后选择Markdown。 一个新的编辑器窗格将打开,您可以在其中放置这些设置:

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

这样,您将仅禁用markdown文件的智能感知。
全局
F1打开命令面板,输入open user settings并按Enter。将打开一个新的编辑器窗格,在其中可以放置这些设置:
// Place your settings in this file to overwrite the default settings
{
    "editor.quickSuggestions": false
}

工作区

工作区设置 允许您在不应用于其他 VS Code 项目的情况下设置自定义设置。 工作区设置文件位于项目中的 .vscode 文件夹下。

按下 F1 打开 命令面板, 输入 打开工作区设置 并按下 Enter。新的编辑器窗格将打开,您可以在其中放置与上面列出的相同的代码片段。

我不知道是否可以将设置与所选文件类型关联。

其他配置选项

除了 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

18
对于像我一样希望禁用 .txt 文件的 IntelliSense 的人,以下内容可以实现此功能: "[plaintext]": { "editor.quickSuggestions": false } - MrDustpan
2
@Frank Nocke的评论现在是错误的,对于.txt文件类型来说,类型应该是纯文本,请参考@MrDustpan的评论,谢谢!您可以执行以下操作: [Ctl-Shift-P] / 配置语言特定设置... / [Enter] / 纯文本 / [Enter] / "editor.quickSuggestions": false / [Ctl-S] - Kai Carver
3
如果你想使用 .mdx 文件来完成这个任务,请注意你需要使用 "[mdx]" 而不是 "[markdown]" - shreyasminocha
3
@FrankNocke 纯文本是一种语言,它被称为“PlainText”,它涵盖了.txt文件。 - Don Rhummy
1
不确定是何时引入的,但至少在vsCode 1.74.3中,editor.quickSuggestions选项不再是布尔值。相反,它是一个哈希表,如下所示: "editor.quickSuggestions": { "other": false, "comments": false, "strings": false } - Alessandro
显示剩余3条评论

10

除了 @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 Code自动插入闭括号、方括号、大括号、单引号、双引号等。

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

总之,这是我使用的设置:

// 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

我认为触发字符可能是与语言相关的。在Python中,句点明确是一个触发字符,在大多数甚至所有编程语言中都是如此。但是,当我输入美元符号(在Python中),即使我设置了 "editor.suggestOnTriggerCharacters": true ,仍然不会有任何反应。 - John Y

2

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

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

0

如果你也觉得Markdown的警告信息干扰了你的工作,想要暂时禁用它们,你可以使用以下方法:

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

当你认为一个文档已经完成时,可以启用它。


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