首页 > 解决方案 > 如何在具有 C++ 扩展名的 VS 代码中禁用函数参数的弹出建议

问题描述

我发现大多数来自 VS 代码中的 C++ 扩展的建议/智能感知很有用。但是在某些情况下,函数参数的特定弹出窗口可能会分散注意力。

如何关闭它(不禁用其他建议/智能感知功能)?

在此处输入图像描述

标签: c++visual-studio-codeintellisense

解决方案


这是IntelliSense的一部分。如果您不想要它,您有几个选项可以摆脱弹出窗口:

关闭弹出窗口

当您想摆脱弹出窗口时按退出键。如果您希望某些事情自动完成/提出建议,但您希望不理会其他代码片段,这将是有益的。


完全禁用

Visual Studio IDE 和 Visual Studio Code 之间的步骤不同,我想在此处提供两者的说明。

Visual Studio (devenv.exe)

  1. Tools > Options
  2. Text Editor在左侧窗格中选择。
  3. 选择您正在使用的语言(在您的情况下,这是 C++,但您也可以为其他语言关闭它)。
  4. 对于 C# 和 Basic,选择IntelliSense. 对于 C/C++,选择Advanced并滚动到该IntelliSense部分。
  5. 对于 C# 和 Basic,选中Show completion list after a character is typed以禁用它。对于 C/C++,您将有几个选项,例如Disable Auto UpdatingDisable SquigglesDisable #include “Auto Complete. 将其中任何一个设置为“True”以关闭它们。

Visual Studio 代码 (code.exe)

您也可以在 VS Code 中禁用自动完成功能,但说明与上述 Visual Studio IDE 不同。以下是您可以在 VS Code 中为 IntelliSense 设置的设置settings.json,其中包括启用/禁用 IntelliSense 某些部分的设置:

{
    // Controls if quick suggestions should show up while typing
    "editor.quickSuggestions": {
        "other": true,
        "comments": false,
        "strings": false
    },

     // Controls whether suggestions should be accepted on commit characters. For example, in JavaScript, the semi-colon (`;`) can be a commit character that accepts a suggestion and types that character.
    "editor.acceptSuggestionOnCommitCharacter": true,

    // Controls if suggestions should be accepted on 'Enter' - in addition to 'Tab'. Helps to avoid ambiguity between inserting new lines or accepting suggestions. The value 'smart' means only accept a suggestion with Enter when it makes a textual change
    "editor.acceptSuggestionOnEnter": "on",

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

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

    // Controls if pressing tab inserts the best suggestion and if tab cycles through other suggestions
    "editor.tabCompletion": "on",

    // Controls whether sorting favours words that appear close to the cursor
    "editor.suggest.localityBonus": true,

    // Controls how suggestions are pre-selected when showing the suggest list
    "editor.suggestSelection": "recentlyUsed",

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

    // Enable parameter hints
    "editor.parameterHints.enabled": true,
}

如果您想完全禁用代码完成,只需将所有内容设置editor.quickSuggestionsfalse.

要仅禁用函数参数建议,"editor.parameterHints.enabled": false请在settings.json.


推荐阅读