切换 Visual Studio Code 中的自动完成功能(不是永久关闭)

切换 Visual Studio Code 中的自动完成功能(不是永久关闭)

希望这是讨论该问题的适当论坛...

我搜索了网络却无果——我发现的每个链接都详细说明了如何永久关闭自动完成功能。有没有什么方法可以轻松打开和关闭自动完成功能?我发现不断出现的一切非常烦人,但我不介意偶尔需要帮助。此时我的 Esc 键将是第一个磨损的键。

系统信息:Linux Mint Uma - XFCE - 带有 compiz 和 emerald

Visual Studio Code 1.63.2 来自 deb [arch=amd64,arm64,armhf]http://packages.microsoft.com/repos/code稳定主线

有什么建议么?

答案1

回答我自己的问题...

我浏览了几个“始终关闭”网站,最后选择了这个我们的代码世界 - 禁用自动完成。正如我在最初的问题中所说,我并不想一直关闭它,我想要一种打开和关闭它的方法。但我怀有希望,因为链接显示了必要的 JSON 内容,而不是描述如何使用 GUI 工具。事实证明,我必须从他们的设置中更改一些内容(毫无疑问,自编写代码以来,VSC 已经发生了变化),但我能够从如此出色的开端中找出我需要的东西。

无论如何,我使用的是 GNU/Linux,所以我的第一步是找到文件“settings.json”。我运行了以下命令,结果出奇地少:

$ locate settings.json

很明显我想要 ~/.config/Code/User/settings.json 。因此,我首先制作了原始文件的安全副本。然后,我根据链接中提供的说明对其进行了编辑。这时,我注意到 VSC 会主动监视设置文件。从那里,我很容易编写几个脚本,将文件从自动完成更改为自动完成。

这些东西似乎在不断发展,所以我所介绍的内容可能不是永远有效。但是,以下内容应该可以帮助任何人入门:

~/.config/Code/User/settings.ac_on.json 的内容

{
"http.proxySupport": "fallback",
"http.proxy": "http://10.0.2.2:3128",
"workbench.startupEditor": "none",
    "[vue]": {
    "editor.defaultFormatter": "rvest.vs-code-prettier-eslint"
},
"diffEditor.ignoreTrimWhitespace": false,
"eslint.format.enable": true,
"eslint.codeActionsOnSave.rules": [
    "autoFixOnSave=true"
],
"editor.formatOnSave": true,
"[javascript]": {
    "editor.defaultFormatter": "rvest.vs-code-prettier-eslint"
},
"editor.defaultFormatter": "rvest.vs-code-prettier-eslint",
"files.autoSave": "onFocusChange",
"vetur.completion.scaffoldSnippetSources": {
    "workspace": "",
    "user": "",
    "vetur": ""
},
"workbench.colorTheme": "Solarized Dark",
"debug.javascript.autoAttachFilter": "onlyWithFlag",
"livePreview.portNumber": 8000,
"livePreview.showServerStatusNotifications": false,
"editor.linkedEditing": true,
"editor.minimap.enabled": false,
"vetur.format.scriptInitialIndent": true,
"vetur.format.styleInitialIndent": true,
"vetur.ignoreProjectWarning": true,
"vetur.useWorkspaceDependencies": true,
"vetur.validation.templateProps": true,
"editor.tabSize": 2,
"editor.wrappingIndent": "indent",
"editor.detectIndentation": false
}

~/.config/Code/User/settings.ac_off.json 的内容

{
"http.proxySupport": "fallback",
"http.proxy": "http://10.0.2.2:3128",
"workbench.startupEditor": "none",
    "[vue]": {
    "editor.defaultFormatter": "rvest.vs-code-prettier-eslint"
},
"diffEditor.ignoreTrimWhitespace": false,
"eslint.format.enable": true,
"eslint.codeActionsOnSave.rules": [
    "autoFixOnSave=true"
],
"editor.formatOnSave": true,
"[javascript]": {
    "editor.defaultFormatter": "rvest.vs-code-prettier-eslint"
},
"editor.defaultFormatter": "rvest.vs-code-prettier-eslint",
"files.autoSave": "onFocusChange",
"vetur.completion.scaffoldSnippetSources": {
    "workspace": "",
    "user": "",
    "vetur": ""
},
"workbench.colorTheme": "Solarized Dark",
"debug.javascript.autoAttachFilter": "onlyWithFlag",
"livePreview.portNumber": 8000,
"livePreview.showServerStatusNotifications": false,
"editor.linkedEditing": true,
"editor.minimap.enabled": false,
"vetur.format.scriptInitialIndent": true,
"vetur.format.styleInitialIndent": true,
"vetur.ignoreProjectWarning": true,
"vetur.useWorkspaceDependencies": true,
"vetur.validation.templateProps": true,
"editor.tabSize": 2,
"editor.detectIndentation": false,

  // OPTIONAL WORD WRAPPING
  // Controls if lines should wrap. The lines will wrap at min(editor.wrappingColumn, viewportWidthInColumns).
  "editor.wordWrap": "off",
  
  // Controls the indentation of wrapped lines. Can be one of 'none', 'same' or 'indent'.
  "editor.wrappingIndent": "none",

  // TURN OFF AUTOCOMPLETION
  // Controls if quick suggestions should show up or not while typing
  "editor.quickSuggestions": false,

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

  // Enables parameter hints
  "editor.parameterHints": false,

  // Controls if the editor should automatically close brackets after opening them.
  // Can be one of 'always', 'languageDefined', 'beforeWhitespace', 'never'.
  "editor.autoClosingBrackets": "never",

  // Controls if the editor should automatically format the line after typing
  "editor.formatOnType": false,

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

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

}

~/bin/ac_on 的内容(一个 bash shell 脚本)

#!/bin/bash
SOURCE=~/.config/Code/User/settings.ac_on.json
TARGET=~/.config/Code/User/settings.json
cat $SOURCE > $TARGET

~/bin/ac_off 的内容(另一个 bash shell 脚本)

#!/bin/bash
SOURCE=~/.config/Code/User/settings.ac_off.json
TARGET=~/.config/Code/User/settings.json
cat $SOURCE > $TARGET

VSC 内置了 bash 提示符,而 ~/bin 位于我的个人路径中。因此,切换自动完成功能就像输入“ac_on”或“ac_off”一样简单。

相关内容