禁用右括号吞咽?

Disable closing bracket swallowing?

当您将光标放在 ])} 前面并键入该字符时,而不是插入它 vscode 只是移过该字符字符,生成 ]*cursor here* 而不是 ]*cursor here*]。因此,每次我实际需要插入一个右括号时,我都需要移动到 )))) 的末尾来键入它,而不是直接键入它。那么有没有办法禁用此行为(不禁用括号自动完成)?

Here is the same question, but for sublime text, and this 家伙提到它是自动关闭括号的副作用。

确实是编辑器的autoClosingBrackets设置的副作用

如果您转到 文件 > 首选项 > 设置 打开设置 JSON 文件,您可以搜索“editor”或“autoClosing”,如果您希望 change/disable 它(默认启用),或者只是复制它来禁用它:

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

有关 VS Code 设置的更多信息以及默认设置列表可在此处找到:https://code.visualstudio.com/docs/getstarted/settings

如果禁用此设置:

  • 键入括号或引号不会自动添加匹配的右括号或引号。
  • 在现有括号前键入(右)括号不会使其成为 "absorbed"。
  • 您必须键入每个右括号或自己引用。
  • 您无法通过选择并仅键入一个 bracket/quote 来自动将所选文本括在方括号或引号中。禁用此选项后,所选文本将替换为您键入的任何内容。

我收到了来自 vscode 项目的 github 的解决方案。
这个对我有用。编辑您的 keybindings.json 添加以下文本:

{
"key": "]",
"command": "editor.action.insertSnippet",
"when": "editorTextFocus",
"args": {
    "snippet": "]"
}
},
{
"key": "Shift+]",
"command": "editor.action.insertSnippet",
"when": "editorTextFocus",
"args": {
    "snippet": "}"
}
},
{
"key": "Shift+0",
"command": "editor.action.insertSnippet",
"when": "editorTextFocus",
"args": {
    "snippet": ")"
}
}

注意:"Shift+0" 用于键盘 (,根据您的键盘布局对其进行编辑。

TL;DR:目前无法禁用此烦人的功能。

我也问过同样的问题

他们的 repo 中有一个未解决的问题。